From d03afe780eb2e07397dbedad36d75e77824b6166 Mon Sep 17 00:00:00 2001 From: Peter Meier Date: Thu, 21 May 2026 11:37:09 +0200 Subject: [PATCH] feat(contact): add Cloudflare Turnstile captcha Client renders explicit Turnstile widget (flexible, light theme) when PUBLIC_TURNSTILE_SITE_KEY is set. Token sent with form payload, server verifies via siteverify endpoint before forwarding to CMS. Skipped entirely when no site key configured (dev fallback). New i18n keys: contact_captcha_pending, contact_server_error_captcha. Deploy workflow forwards PUBLIC_TURNSTILE_SITE_KEY + TURNSTILE_SECRET. Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/deploy.yml | 2 + .../internal/ContactFormComponent.svelte | 95 ++++++++++++++++++- src/lib/translations.ts | 2 + src/routes/api/contact/+server.ts | 31 ++++++ 4 files changed, 129 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 659379e..233f669 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -89,6 +89,8 @@ jobs: IMAGE_CACHE_DIR=/data/image-cache PUBLIC_UMAMI_SCRIPT_URL=https://cloud.umami.is/script.js PUBLIC_UMAMI_WEBSITE_ID=${{ secrets.PUBLIC_UMAMI_WEBSITE_ID }} + PUBLIC_TURNSTILE_SITE_KEY=${{ secrets.PUBLIC_TURNSTILE_SITE_KEY }} + TURNSTILE_SECRET=${{ secrets.TURNSTILE_SECRET }} ENVEOF - name: Pull and restart container diff --git a/src/lib/components/internal/ContactFormComponent.svelte b/src/lib/components/internal/ContactFormComponent.svelte index 426cd58..d20d8d6 100644 --- a/src/lib/components/internal/ContactFormComponent.svelte +++ b/src/lib/components/internal/ContactFormComponent.svelte @@ -1,4 +1,6 @@ @@ -187,6 +276,10 @@

{t(T.contact_privacy_note)}

+ {#if TURNSTILE_ENABLED} +
+ {/if} + {#if serverError}