Reset turnstile on submission request failure
This commit is contained in:
parent
2db6acaf1c
commit
d9bebf9a09
@ -66,6 +66,8 @@ export default function () {
|
||||
);
|
||||
}, []);
|
||||
|
||||
const { logged_in, site_key } = useLoaderData<typeof loader>();
|
||||
|
||||
async function submit() {
|
||||
const usernames = (
|
||||
document.getElementById("usernames") as HTMLInputElement
|
||||
@ -112,13 +114,21 @@ export default function () {
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
if (!submitReq.ok)
|
||||
if (!submitReq.ok) {
|
||||
if (!logged_in) {
|
||||
try {
|
||||
// @ts-expect-error
|
||||
turnstile.reset();
|
||||
} catch {}
|
||||
}
|
||||
|
||||
return toast({
|
||||
description: ((await submitReq.json()) as { error: string }).error,
|
||||
isClosable: true,
|
||||
status: "error",
|
||||
title: "Error",
|
||||
});
|
||||
}
|
||||
|
||||
const { id, upload_url }: { id: string; upload_url: string } =
|
||||
await submitReq.json();
|
||||
@ -181,8 +191,6 @@ export default function () {
|
||||
sessionStorage.setItem("REPORT_SUCCESS", "1");
|
||||
}
|
||||
|
||||
const { logged_in, site_key } = useLoaderData<typeof loader>();
|
||||
|
||||
useEffect(() => {
|
||||
if (logged_in) return;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user