Skip to content
Snippets Groups Projects
Commit 8ef14cbb authored by Embruch, Gerd's avatar Embruch, Gerd
Browse files

fixed password reset

parent 2b2fcfc5
No related branches found
No related tags found
No related merge requests found
......@@ -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
}}>
......
......@@ -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>
......
......@@ -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',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment