Make captcha actually load

This commit is contained in:
regalijan 2023-10-19 16:49:23 -04:00
parent 004af30f9a
commit 4409b293af
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -39,6 +39,7 @@ export default function () {
const [supportsRequestStreams, setSupportsRequestStreams] = useState(false); const [supportsRequestStreams, setSupportsRequestStreams] = useState(false);
const toast = useToast(); const toast = useToast();
const [uploading, setUploading] = useState(false); const [uploading, setUploading] = useState(false);
const [turnstileToken, setTurnstileToken] = useState("");
useEffect(() => { useEffect(() => {
if (sessionStorage.getItem("REPORT_SUCCESS")) { if (sessionStorage.getItem("REPORT_SUCCESS")) {
@ -182,6 +183,17 @@ export default function () {
const { logged_in, site_key } = useLoaderData<typeof loader>(); 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 ? ( return showSuccess ? (
<Success <Success
heading="Report Submitted" heading="Report Submitted"
@ -212,6 +224,7 @@ export default function () {
<input id="evidence" type="file" /> <input id="evidence" type="file" />
</FormControl> </FormControl>
<br /> <br />
<div className="cf-turnstile" data-sitekey={site_key}></div>
<br /> <br />
<Text> <Text>
By submitting this form, you agree to the{" "} By submitting this form, you agree to the{" "}
@ -243,18 +256,7 @@ export default function () {
) : null} ) : null}
</CircularProgress> </CircularProgress>
</HStack> </HStack>
<div
className="cf-turnstile"
data-sitekey={useLoaderData<typeof loader>()}
></div>
</Container> </Container>
{logged_in ? null : (
<script
src="https://challenges.cloudflare.com/turnstile/v0/api.js"
async
defer
></script>
)}
</> </>
); );
} }