From 94246484b0fd33a28470b2bc3341f2e1987cae46 Mon Sep 17 00:00:00 2001 From: Captain Jack Sparrow <163903675+sussy-code@users.noreply.github.com> Date: Wed, 5 Jun 2024 01:57:25 +0000 Subject: [PATCH] Fix turnstiles mostly! --- src/pages/parts/admin/WorkerTestPart.tsx | 20 +++++--------------- src/stores/turnstile/index.tsx | 5 +---- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/pages/parts/admin/WorkerTestPart.tsx b/src/pages/parts/admin/WorkerTestPart.tsx index 9fd01004..033640ad 100644 --- a/src/pages/parts/admin/WorkerTestPart.tsx +++ b/src/pages/parts/admin/WorkerTestPart.tsx @@ -90,21 +90,11 @@ export function WorkerTestPart() { } catch (err) { const error = err as Error; error.message = error.message.replace(worker.url, "WORKER_URL"); - if ( - error.message === - '[Cloudflare Turnstile] Invalid or missing type for parameter "sitekey", expected "string", got "object".' - ) { - updateWorker(worker.id, { - id: worker.id, - status: "success", - }); - } else { - updateWorker(worker.id, { - id: worker.id, - status: "error", - error, - }); - } + updateWorker(worker.id, { + id: worker.id, + status: "error", + error, + }); } }); diff --git a/src/stores/turnstile/index.tsx b/src/stores/turnstile/index.tsx index b88e0e09..7a52c26b 100644 --- a/src/stores/turnstile/index.tsx +++ b/src/stores/turnstile/index.tsx @@ -81,9 +81,6 @@ 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}`), {}, @@ -101,7 +98,7 @@ export function TurnstileProvider(props: { isInPopout?: boolean; onUpdateShow?: (show: boolean) => void; }) { - const siteKey = conf().TURNSTILE_KEY?.toString(); + const siteKey = conf().TURNSTILE_KEY; const idRef = useRef(null); const setTurnstile = useTurnstileStore((s) => s.setTurnstile); const processToken = useTurnstileStore((s) => s.processToken);