From 4409b293afc5fc987f6dcb9b566a5eb567702e1e Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:49:23 -0400 Subject: [PATCH] Make captcha actually load --- app/routes/report.tsx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/routes/report.tsx b/app/routes/report.tsx index 5395e8b..c5ffb9a 100644 --- a/app/routes/report.tsx +++ b/app/routes/report.tsx @@ -39,6 +39,7 @@ export default function () { const [supportsRequestStreams, setSupportsRequestStreams] = useState(false); const toast = useToast(); const [uploading, setUploading] = useState(false); + const [turnstileToken, setTurnstileToken] = useState(""); useEffect(() => { if (sessionStorage.getItem("REPORT_SUCCESS")) { @@ -182,6 +183,17 @@ export default function () { const { logged_in, site_key } = useLoaderData(); + useEffect(() => { + if (logged_in) return; + + const script = document.createElement("script"); + script.async = true; + script.defer = true; + script.src = "https://challenges.cloudflare.com/turnstile/v0/api.js"; + + document.body.appendChild(script); + }, [logged_in]); + return showSuccess ? (
+

By submitting this form, you agree to the{" "} @@ -243,18 +256,7 @@ export default function () { ) : null} -
()} - >
- {logged_in ? null : ( - - )} ); }