diff --git a/resources/scripts/components/auth/ForgotPasswordContainer.tsx b/resources/scripts/components/auth/ForgotPasswordContainer.tsx index f82b76e2..8b75511d 100644 --- a/resources/scripts/components/auth/ForgotPasswordContainer.tsx +++ b/resources/scripts/components/auth/ForgotPasswordContainer.tsx @@ -30,7 +30,13 @@ export default () => { // If there is no token in the state yet, request the token and then abort this submit request // since it will be re-submitted when the recaptcha data is returned by the component. if (recaptchaEnabled && !token) { - ref.current!.execute().catch(error => console.error(error)); + ref.current!.execute().catch(error => { + console.error(error); + + setSubmitting(false); + addFlash({ type: 'error', title: 'Error', message: httpErrorToHuman(error) }); + }); + return; } @@ -43,7 +49,12 @@ export default () => { console.error(error); addFlash({ type: 'error', title: 'Error', message: httpErrorToHuman(error) }); }) - .then(() => setSubmitting(false)); + .then(() => { + setToken(''); + if (ref.current) ref.current.reset(); + + setSubmitting(false); + }); }; return ( diff --git a/resources/scripts/components/auth/LoginContainer.tsx b/resources/scripts/components/auth/LoginContainer.tsx index 35b2ba88..d74ada61 100644 --- a/resources/scripts/components/auth/LoginContainer.tsx +++ b/resources/scripts/components/auth/LoginContainer.tsx @@ -29,7 +29,13 @@ const LoginContainer = ({ history }: RouteComponentProps) => { // If there is no token in the state yet, request the token and then abort this submit request // since it will be re-submitted when the recaptcha data is returned by the component. if (recaptchaEnabled && !token) { - ref.current!.execute().catch(error => console.error(error)); + ref.current!.execute().catch(error => { + console.error(error); + + setSubmitting(false); + clearAndAddHttpError({ error }); + }); + return; } @@ -46,6 +52,9 @@ const LoginContainer = ({ history }: RouteComponentProps) => { .catch(error => { console.error(error); + setToken(''); + if (ref.current) ref.current.reset(); + setSubmitting(false); clearAndAddHttpError({ error }); }); @@ -63,23 +72,23 @@ const LoginContainer = ({ history }: RouteComponentProps) => { {({ isSubmitting, setSubmitting, submitForm }) => (
-