fix: 🐛 set errors on reset password form
This commit is contained in:
parent
76e83eac49
commit
1f09667acb
3 changed files with 14 additions and 4 deletions
|
|
@ -86,7 +86,7 @@ class AuthenticatedSessionController extends Controller
|
|||
|
||||
return $status === Password::RESET_LINK_SENT
|
||||
? to_route(config('uwil-backend.routes.name') . 'login')
|
||||
: back()->with('error', trans('passwords.throttled'));
|
||||
: back()->withErrors(['email' => trans('auth.throttled')]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -100,8 +100,8 @@ class AuthenticatedSessionController extends Controller
|
|||
$status = Password::broker('backend')->sendResetLink(['email' => $user->email]);
|
||||
|
||||
return $status === Password::RESET_LINK_SENT
|
||||
? back()->with('success', trans('passwords.sent'))
|
||||
: back()->with('error', trans('passwords.throttled'));
|
||||
? back()
|
||||
: back()->withErrors(['email' => trans('auth.throttled')]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -145,6 +145,6 @@ class AuthenticatedSessionController extends Controller
|
|||
|
||||
return $status === Password::PASSWORD_RESET
|
||||
? to_route(config('uwil-backend.routes.name') . 'login')
|
||||
: back()->with('error', trans('passwords.throttled'));
|
||||
: back()->withErrors(['email' => trans("auth.token")]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,4 +40,6 @@ return [
|
|||
mot de passe en cliquant sur le bouton suivant:',
|
||||
'email_title_reset_password' => 'Réinitialisation du mot de passe',
|
||||
'email_title_reset_complete' => 'Mot de passe modifié',
|
||||
'token' => 'Ce lien de réinitialisation du mot de passe est invalide ou expiré.',
|
||||
'throttled' => 'Veuillez patienter avant de réessayer.',
|
||||
];
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ type ResetPasswordProps = {
|
|||
export default function ResetPassword({ token, email }: ResetPasswordProps) {
|
||||
const resetSent = useTrans("auth.reset_sent");
|
||||
const resetSentDesc = useTrans("auth.reset_sent_desc");
|
||||
const errorTitle = useTrans("auth.reset_failed");
|
||||
|
||||
const { post, setData, processing } = useForm({
|
||||
token,
|
||||
|
|
@ -42,6 +43,13 @@ export default function ResetPassword({ token, email }: ResetPasswordProps) {
|
|||
description: resetSentDesc,
|
||||
});
|
||||
},
|
||||
onError: (errors) => {
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: errorTitle,
|
||||
description: Object.values(errors).join(", "),
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue