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