chore: CAPTCHA

This commit is contained in:
Lluis Agusti
2025-07-14 15:23:39 +04:00
parent 6feedafd7d
commit 81a09738dc
4 changed files with 32 additions and 20 deletions

View File

@@ -21,6 +21,7 @@ export default function LoginPage() {
isLoading,
isLoggedIn,
isCloudEnv,
shouldNotRenderCaptcha,
isUserLoading,
isGoogleLoading,
showNotAllowedModal,
@@ -85,16 +86,18 @@ export default function LoginPage() {
/>
{/* Turnstile CAPTCHA Component */}
<Turnstile
key={captchaKey}
siteKey={turnstile.siteKey}
onVerify={turnstile.handleVerify}
onExpire={turnstile.handleExpire}
onError={turnstile.handleError}
setWidgetId={turnstile.setWidgetId}
action="login"
shouldRender={turnstile.shouldRender}
/>
{shouldNotRenderCaptcha ? null : (
<Turnstile
key={captchaKey}
siteKey={turnstile.siteKey}
onVerify={turnstile.handleVerify}
onExpire={turnstile.handleExpire}
onError={turnstile.handleError}
setWidgetId={turnstile.setWidgetId}
action="login"
shouldRender={turnstile.shouldRender}
/>
)}
<Button
variant="primary"

View File

@@ -28,6 +28,8 @@ export function useLoginPage() {
resetOnError: true,
});
const shouldNotRenderCaptcha = isVercelPreview || turnstile.verified;
const form = useForm<z.infer<typeof loginFormSchema>>({
resolver: zodResolver(loginFormSchema),
defaultValues: {
@@ -125,6 +127,7 @@ export function useLoginPage() {
isLoading,
isCloudEnv,
isUserLoading,
shouldNotRenderCaptcha,
isGoogleLoading,
showNotAllowedModal,
isSupabaseAvailable: !!supabase,

View File

@@ -32,6 +32,7 @@ export default function SignupPage() {
isLoading,
isCloudEnv,
isUserLoading,
shouldNotRenderCaptcha,
isGoogleLoading,
showNotAllowedModal,
isSupabaseAvailable,
@@ -163,16 +164,18 @@ export default function SignupPage() {
/>
{/* Turnstile CAPTCHA Component */}
<Turnstile
key={captchaKey}
siteKey={turnstile.siteKey}
onVerify={turnstile.handleVerify}
onExpire={turnstile.handleExpire}
onError={turnstile.handleError}
setWidgetId={turnstile.setWidgetId}
action="signup"
shouldRender={turnstile.shouldRender}
/>
{shouldNotRenderCaptcha ? null : (
<Turnstile
key={captchaKey}
siteKey={turnstile.siteKey}
onVerify={turnstile.handleVerify}
onExpire={turnstile.handleExpire}
onError={turnstile.handleError}
setWidgetId={turnstile.setWidgetId}
action="signup"
shouldRender={turnstile.shouldRender}
/>
)}
<Button
variant="primary"

View File

@@ -30,6 +30,8 @@ export function useSignupPage() {
resetOnError: true,
});
const shouldNotRenderCaptcha = isVercelPreview || turnstile.verified;
const resetCaptcha = useCallback(() => {
setCaptchaKey((k) => k + 1);
turnstile.reset();
@@ -132,6 +134,7 @@ export function useSignupPage() {
isCloudEnv,
isUserLoading,
isGoogleLoading,
shouldNotRenderCaptcha,
showNotAllowedModal,
isSupabaseAvailable: !!supabase,
handleSubmit: form.handleSubmit(handleSignup),