Commit 32a9f92b authored by tom goriunov's avatar tom goriunov Committed by GitHub

Merge pull request #2652 from blockscout/release/v1-38-2

Fixes for release v1.38.2
parents 07388c62 513e395d
......@@ -8,6 +8,12 @@ interface Props {
}
const ReCaptchaInvisible = ({ disabledFeatureMessage }: Props, ref: React.Ref<ReCaptcha>) => {
const [ attempt, setAttempt ] = React.useState(0);
const handleChange = React.useCallback(() => {
setAttempt(attempt + 1);
}, [ attempt ]);
if (!config.services.reCaptchaV2.siteKey) {
return disabledFeatureMessage ?? null;
}
......@@ -15,8 +21,10 @@ const ReCaptchaInvisible = ({ disabledFeatureMessage }: Props, ref: React.Ref<Re
return (
<ReCaptcha
ref={ ref }
key={ attempt }
sitekey={ config.services.reCaptchaV2.siteKey }
size="invisible"
onChange={ handleChange }
/>
);
};
......
......@@ -53,7 +53,7 @@ const AuthGuard = ({ children, onAuthSuccess, ensureEmail }: Props) => {
{ authModal.isOpen && (
<AuthModal
onClose={ handleModalClose }
initialScreen={ profileQuery.data && !profileQuery.data.email && ensureEmail ? { type: 'email' } : { type: 'select_method' } }
initialScreen={ profileQuery.data && !profileQuery.data.email && ensureEmail ? { type: 'email', isAuth: true } : { type: 'select_method' } }
/>
) }
</>
......
......@@ -28,7 +28,6 @@ const AuthModalScreenOtpCode = ({ email, onSuccess, isAuth }: Props) => {
const toast = useToast();
const recaptcha = useReCaptcha();
const [ isCodeSending, setIsCodeSending ] = React.useState(false);
const [ resendAttempts, setResendAttempts ] = React.useState(0);
const formApi = useForm<OtpCodeFormFields>({
mode: 'onBlur',
......@@ -96,7 +95,6 @@ const AuthModalScreenOtpCode = ({ email, onSuccess, isAuth }: Props) => {
description: apiError?.message || getErrorMessage(error) || 'Something went wrong',
});
} finally {
setResendAttempts((prev) => prev + 1);
setIsCodeSending(false);
}
}, [ apiFetch, email, formApi, toast, recaptcha ]);
......@@ -113,7 +111,7 @@ const AuthModalScreenOtpCode = ({ email, onSuccess, isAuth }: Props) => {
and enter your code below.
</Text>
<AuthModalFieldOtpCode isDisabled={ isCodeSending }/>
<ReCaptcha key={ resendAttempts } ref={ recaptcha.ref }/>
<ReCaptcha ref={ recaptcha.ref }/>
<Button
variant="link"
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