Fix some issues with init of turnstile hopefully

This commit is contained in:
Captain Jack Sparrow 2024-06-04 18:44:24 +00:00
parent 86a3c42887
commit 384cc43936
2 changed files with 5 additions and 1 deletions

View File

@ -9,7 +9,7 @@ import {
useInternalOverlayRouter,
useRouterAnchorUpdate,
} from "@/hooks/useOverlayRouter";
import { TurnstileProvider } from "@/stores/turnstile";
import { TurnstileProvider, getTurnstile } from "@/stores/turnstile";
export interface OverlayProps {
id: string;
@ -20,6 +20,7 @@ export interface OverlayProps {
function TurnstileInteractive() {
const { t } = useTranslation();
const [show, setShow] = useState(false);
getTurnstile();
// this may not rerender with different dom structure, must be exactly the same always
return (

View File

@ -81,6 +81,9 @@ export async function getTurnstileToken() {
const turnstile = getTurnstile();
try {
// I hate turnstile
if (turnstile.controls.isExpired()) {
turnstile.controls.reset();
}
(window as any).turnstile.execute(
document.querySelector(`#${turnstile.id}`),
{},