Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make captcha actually load
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 004af30 commit 4409b29
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions app/routes/report.tsx
Expand Up @@ -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")) {
Expand Down Expand Up @@ -182,6 +183,17 @@ export default function () {

const { logged_in, site_key } = useLoaderData<typeof loader>();

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 ? (
<Success
heading="Report Submitted"
Expand Down Expand Up @@ -212,6 +224,7 @@ export default function () {
<input id="evidence" type="file" />
</FormControl>
<br />
<div className="cf-turnstile" data-sitekey={site_key}></div>
<br />
<Text>
By submitting this form, you agree to the{" "}
Expand Down Expand Up @@ -243,18 +256,7 @@ export default function () {
) : null}
</CircularProgress>
</HStack>
<div
className="cf-turnstile"
data-sitekey={useLoaderData<typeof loader>()}
></div>
</Container>
{logged_in ? null : (
<script
src="https://challenges.cloudflare.com/turnstile/v0/api.js"
async
defer
></script>
)}
</>
);
}

0 comments on commit 4409b29

Please sign in to comment.