Fixed turnstile

This commit is contained in:
2026-10-15 15:27:43 +02:00
parent 7ef7927e38
commit 3bab8a0697
58 changed files with 1182 additions and 322 deletions
+8 -1
View File
@@ -24,6 +24,12 @@ export type SubmitFormArgs = {
*/
maxPerMinute?: number
payload: BasePayload
/**
* Turnstile can't be verified because of OUR side (missing/wrong secret,
* Cloudflare unreachable): 'allow' (default) accepts the submission and shows
* the problem in the panel; 'reject' refuses it.
*/
turnstileOnConfigError?: 'allow' | 'reject'
/** Turnstile token; when present it is verified, when absent it is skipped. */
turnstileToken?: string
}
@@ -87,6 +93,7 @@ export async function submitForm({
ip,
maxPerMinute = 5,
payload,
turnstileOnConfigError = 'allow',
turnstileToken,
}: SubmitFormArgs): Promise<SubmitFormResult> {
// 1. Rate limit — cheapest gate, drops a flood before any real work.
@@ -98,7 +105,7 @@ export async function submitForm({
// 2. Turnstile — verify when a token is supplied; reject on failure.
if (turnstileToken !== undefined) {
const ok = await verifyTurnstile({ ip, payload, token: turnstileToken })
const ok = await verifyTurnstile({ ip, onConfigError: turnstileOnConfigError, payload, token: turnstileToken })
if (!ok) {
return { reason: 'turnstile', success: false }
}