Antoine Moreaux
2025-06-27 10:44:10 +02:00
committed by GitHub
parent 3241539db9
commit c3f8a25d25
3 changed files with 23 additions and 24 deletions
@@ -4,7 +4,6 @@ import { captchaTokenState } from '@/captcha/states/captchaTokenState';
import { isRequestingCaptchaTokenState } from '@/captcha/states/isRequestingCaptchaTokenState';
import { isCaptchaRequiredForPath } from '@/captcha/utils/isCaptchaRequiredForPath';
import { captchaState } from '@/client-config/states/captchaState';
import { useLocation } from 'react-router-dom';
import { CaptchaDriverType } from '~/generated-metadata/graphql';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
@@ -21,12 +20,10 @@ export const useRequestFreshCaptchaToken = () => {
isRequestingCaptchaTokenState,
);
const location = useLocation();
const requestFreshCaptchaToken = useRecoilCallback(
({ snapshot }) =>
async () => {
if (!isCaptchaRequiredForPath(location.pathname)) {
if (!isCaptchaRequiredForPath(window.location.pathname)) {
return;
}
@@ -47,12 +44,6 @@ export const useRequestFreshCaptchaToken = () => {
action: 'submit',
})
.then((token: string) => {
// TODO remove this log once debugged
// eslint-disable-next-line no-console
console.log(
'Google Recaptcha token generated at',
new Date().toISOString(),
);
setCaptchaToken(token);
setIsRequestingCaptchaToken(false);
});
@@ -69,7 +60,7 @@ export const useRequestFreshCaptchaToken = () => {
});
}
},
[location.pathname, setCaptchaToken, setIsRequestingCaptchaToken],
[setCaptchaToken, setIsRequestingCaptchaToken],
);
return { requestFreshCaptchaToken };