diff --git a/src/contexts/Auth/AuthState.jsx b/src/contexts/Auth/AuthState.jsx index 277791613993e43a69be20da23786cb50ef7b198..64a32e5c0a55609fef257e46275d4979088d8b04 100755 --- a/src/contexts/Auth/AuthState.jsx +++ b/src/contexts/Auth/AuthState.jsx @@ -56,13 +56,9 @@ function AuthState({ children }) { // ### REQUEST PASSWORD RESET function requestPasswordReset(email) { - return api.post('/users/requestpasswordreset', { email }); + return api.post('/auth/password-reset', { email }); } - // ### REQUEST PASSWORD RESET - function requestEmailReset(email) { - return api.post('/users/requestemailchange', { email }); - } // ### RETURN return ( @@ -73,7 +69,6 @@ function AuthState({ children }) { logout, requestVerificationToken, requestPasswordReset, - requestEmailReset, USER_ACTIONS, dispatchCurrentUser }}> diff --git a/src/pages/User/ResetPassword.jsx b/src/pages/User/ResetPassword.jsx index 29d006714e320e0600867e81b46eee12fa1eb3b7..72865b34adfac55d04be2f9711a9e11138be426e 100644 --- a/src/pages/User/ResetPassword.jsx +++ b/src/pages/User/ResetPassword.jsx @@ -18,13 +18,14 @@ function ResetPasswordForm() { // VALIDATION SCHEMA // ################################# const schema = z.object({ + token: z.string().min(1), password: z.string().refine((val) => val && isStrongPassword(val), { message: 'This field must be min 6 characters long and contain uppercase, lowercase, number, specialchar.', }), - passwordConfirm: z.string(), - }).refine((data) => data.password === data.passwordConfirm, { + confirmPassword: z.string(), + }).refine((data) => data.password === data.confirmPassword, { message: "Passwords don't match", - path: ["passwordConfirm"], + path: ["confirmPassword"], }); // ################################# @@ -54,11 +55,10 @@ function ResetPasswordForm() { // ### HANDLE SUBMITTING FORM async function handleSendForm(inputs) { - // TRY UPDATE try { // send data - const result = await api.post(`/users/confirmpasswordreset`, inputs); + const result = await api.patch(`/auth/password-reset`, inputs); await logout(); redirect('/login'); // set flash message @@ -83,7 +83,7 @@ function ResetPasswordForm() { <form onSubmit={methods.handleSubmit(handleSendForm)}> <Input name='token' type='text' title='confirm token' className='h-16' /> <Input name='password' type='password' title='new password' className='h-16' autoFocus={true} /> - <Input name='passwordConfirm' type='password' title='confirm password' className='h-16' /> + <Input name='confirmPassword' type='password' title='confirm password' className='h-16' /> <Submit value='Reset' /> </form> diff --git a/src/routes/Sitemap.jsx b/src/routes/Sitemap.jsx index 3b99f040621ec9f74750e30b43c2ead7a2dabb33..17567fff259867dc23a2aff8433d9e7efd6e3242 100644 --- a/src/routes/Sitemap.jsx +++ b/src/routes/Sitemap.jsx @@ -27,22 +27,6 @@ export const sitemap = [{ ] }, - // REQUEST CHANGE EMAIL ADDRESS - { - title: 'Change eMail', - path: '/change_email', - handle: { crumb: () => <Link to="/change_email">Change eMail</Link> }, - children: [ - { index: true, element: loadComponent('User/RequestChangeMail') }, - // CHANGE EMAIL ADDRESS - { - title: 'Change eMail', - path: ':token', - hidden: true, - element: loadComponent('User/ChangeMail') - } - ] - }, // LOGOUT { title: 'Logout',