Skip to content

Commit

Permalink
Fix turnstiles mostly!
Browse files Browse the repository at this point in the history
  • Loading branch information
Captain Jack Sparrow committed Jun 5, 2024
1 parent 02a3fbc commit 9424648
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
20 changes: 5 additions & 15 deletions src/pages/parts/admin/WorkerTestPart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
});

Expand Down
5 changes: 1 addition & 4 deletions src/stores/turnstile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`),
{},
Expand All @@ -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<string | null>(null);
const setTurnstile = useTurnstileStore((s) => s.setTurnstile);
const processToken = useTurnstileStore((s) => s.processToken);
Expand Down

0 comments on commit 9424648

Please sign in to comment.