Commit 07b7d724 authored by tom goriunov's avatar tom goriunov Committed by GitHub

Reset the reCAPTCHA after the user attempts to resend the OTP (#2645)

parent 5557c1e1
...@@ -28,6 +28,7 @@ const AuthModalScreenOtpCode = ({ email, onSuccess, isAuth }: Props) => { ...@@ -28,6 +28,7 @@ const AuthModalScreenOtpCode = ({ email, onSuccess, isAuth }: Props) => {
const toast = useToast(); const toast = useToast();
const recaptcha = useReCaptcha(); const recaptcha = useReCaptcha();
const [ isCodeSending, setIsCodeSending ] = React.useState(false); const [ isCodeSending, setIsCodeSending ] = React.useState(false);
const [ resendAttempts, setResendAttempts ] = React.useState(0);
const formApi = useForm<OtpCodeFormFields>({ const formApi = useForm<OtpCodeFormFields>({
mode: 'onBlur', mode: 'onBlur',
...@@ -95,6 +96,7 @@ const AuthModalScreenOtpCode = ({ email, onSuccess, isAuth }: Props) => { ...@@ -95,6 +96,7 @@ const AuthModalScreenOtpCode = ({ email, onSuccess, isAuth }: Props) => {
description: apiError?.message || getErrorMessage(error) || 'Something went wrong', description: apiError?.message || getErrorMessage(error) || 'Something went wrong',
}); });
} finally { } finally {
setResendAttempts((prev) => prev + 1);
setIsCodeSending(false); setIsCodeSending(false);
} }
}, [ apiFetch, email, formApi, toast, recaptcha ]); }, [ apiFetch, email, formApi, toast, recaptcha ]);
...@@ -111,7 +113,7 @@ const AuthModalScreenOtpCode = ({ email, onSuccess, isAuth }: Props) => { ...@@ -111,7 +113,7 @@ const AuthModalScreenOtpCode = ({ email, onSuccess, isAuth }: Props) => {
and enter your code below. and enter your code below.
</Text> </Text>
<AuthModalFieldOtpCode isDisabled={ isCodeSending }/> <AuthModalFieldOtpCode isDisabled={ isCodeSending }/>
<ReCaptcha ref={ recaptcha.ref }/> <ReCaptcha key={ resendAttempts } ref={ recaptcha.ref }/>
<Button <Button
variant="link" variant="link"
display="flex" display="flex"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment