At least attempt to handle turnstile errors

This commit is contained in:
Regalijan 2023-11-10 23:25:17 -05:00
parent cc8c03a2ea
commit 92e6f2e256
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -319,7 +319,11 @@ export default function () {
<Textarea id="description" maxLength={512} /> <Textarea id="description" maxLength={512} />
</FormControl> </FormControl>
<br /> <br />
<div className="cf-turnstile" data-sitekey={site_key}></div> <div
className="cf-turnstile"
data-error-callback="onTurnstileError"
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{" "}
@ -355,6 +359,25 @@ export default function () {
</CircularProgress> </CircularProgress>
</HStack> </HStack>
</Container> </Container>
<script>
{`
function onTurnstileError(code) {
const messages = {
110500: "Your browser is too old to complete the captcha, please update it.",
110510: "Something unexpected happened, please try disabling all extensions and refresh the page. If this does not solve the problem, use a different browser.",
110600: "Failed to solve the captcha, please refresh the page to try again.",
200010: "Invalid cache, please clear your cache and site data in your browser's settings.",
200100: "Your device's clock is wrong, please fix it.",
};
const message = messages[code];
alert(message ?? \`Unknown error when solving captcha. Error \${code}\`);
return true;
}
`}
</script>
</> </>
); );
} }