fix(twenty-front): error on captcha initialisation (#11039)

This commit is contained in:
Antoine Moreaux
2025-03-19 17:09:35 +01:00
committed by GitHub
parent cfdb3f5778
commit 28028ca4c0
6 changed files with 72 additions and 69 deletions

View File

@ -24,6 +24,7 @@ import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope
import { isDefined } from 'twenty-shared';
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
import { usePageChangeEffectNavigateLocation } from '~/hooks/usePageChangeEffectNavigateLocation';
import { isCaptchaRequiredForPath } from '@/captcha/utils/isCaptchaRequiredForPath';
// TODO: break down into smaller functions and / or hooks
// - moved usePageChangeEffectNavigateLocation into dedicated hook
@ -178,15 +179,10 @@ export const PageChangeEffect = () => {
const isCaptchaScriptLoaded = useRecoilValue(isCaptchaScriptLoadedState);
useEffect(() => {
if (
isCaptchaScriptLoaded &&
(isMatchingLocation(AppPath.SignInUp) ||
isMatchingLocation(AppPath.Invite) ||
isMatchingLocation(AppPath.ResetPassword))
) {
if (isCaptchaScriptLoaded && isCaptchaRequiredForPath(location.pathname)) {
requestFreshCaptchaToken();
}
}, [isCaptchaScriptLoaded, isMatchingLocation, requestFreshCaptchaToken]);
}, [isCaptchaScriptLoaded, location.pathname, requestFreshCaptchaToken]);
return <></>;
};