diff --git a/README.md b/README.md index a85818d..87cbfea 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,9 @@ VITE_TURNSTILE_SITE_KEY Set `VITE_TURNSTILE_SITE_KEY` at frontend build time to show Cloudflare Turnstile on the login page. +If `TURNSTILE_SECRET` is set but the login page does not show the verification +widget, rebuild the frontend image with `VITE_TURNSTILE_SITE_KEY` available. + ## Validation ```bash diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index f0f2e54..1cba751 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -23,6 +23,10 @@ declare global { const turnstileSiteKey = import.meta.env.VITE_TURNSTILE_SITE_KEY; const turnstileScriptId = 'turnstile-api-script'; +const securityUnavailableMessage = 'Não foi possível carregar a verificação de segurança. Atualize a página e tente novamente.'; +const securityConfigurationMessage = 'Verificação de segurança indisponível. Entre em contato com o administrador.'; +const securityRequiredMessage = 'Conclua a verificação de segurança para continuar.'; +const securityFailedMessage = 'Não foi possível validar a verificação de segurança. Atualize a página e tente novamente.'; const Login = () => { const [email, setEmail] = useState(''); @@ -58,7 +62,7 @@ const Login = () => { 'error-callback': () => { setCaptchaToken(''); setCaptchaReady(false); - setError('Não foi possível carregar a verificação anti-bot.'); + setError(securityUnavailableMessage); }, }); setCaptchaReady(true); @@ -83,7 +87,7 @@ const Login = () => { script.addEventListener('load', renderCaptcha, { once: true }); script.addEventListener('error', () => { setCaptchaReady(false); - setError('Não foi possível carregar a verificação anti-bot.'); + setError(securityUnavailableMessage); }, { once: true }); document.head.appendChild(script); @@ -93,7 +97,7 @@ const Login = () => { const handleLogin = async (e: React.FormEvent) => { e.preventDefault(); if (captchaEnabled && !captchaToken) { - setError('Confirme a verificação anti-bot antes de entrar.'); + setError(securityRequiredMessage); return; } @@ -105,7 +109,7 @@ const Login = () => { if (result === 'success') { navigate('/graph'); } else if (result === 'captcha_failed') { - setError('A verificação anti-bot falhou. Tente novamente.'); + setError(captchaEnabled ? securityFailedMessage : securityConfigurationMessage); if (captchaEnabled) { setCaptchaToken(''); window.turnstile?.reset(captchaWidgetIdRef.current ?? undefined); @@ -173,12 +177,12 @@ const Login = () => {
Verificação anti-bot indisponível.
+Verificação de segurança indisponível.
)}{error}
} + {error &&{error}
}