From d2f938803b94d21a46d90ea7ca41454578c7b8f0 Mon Sep 17 00:00:00 2001 From: Julien Nahum Date: Thu, 27 Feb 2025 15:00:56 +0800 Subject: [PATCH] Improve Captcha Provider Handling and Availability Checks - Add conditional rendering for captcha based on site key availability - Dynamically generate captcha options based on configured providers - Prevent displaying captcha input when no providers are configured - Add runtime config checks for captcha site keys --- .../forms/components/CaptchaInput.vue | 11 ++++++++- client/components/open/forms/OpenForm.vue | 17 ++++++++++++- .../form-components/FormCustomSeo.vue | 2 +- .../form-components/FormSecurityAccess.vue | 24 +++++++++++++++---- 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/client/components/forms/components/CaptchaInput.vue b/client/components/forms/components/CaptchaInput.vue index d38647f3..7b2ab978 100644 --- a/client/components/forms/components/CaptchaInput.vue +++ b/client/components/forms/components/CaptchaInput.vue @@ -1,6 +1,6 @@ -
+

Link Privacy

diff --git a/client/components/open/forms/components/form-components/FormSecurityAccess.vue b/client/components/open/forms/components/form-components/FormSecurityAccess.vue index 2a5edea3..fd9ad195 100644 --- a/client/components/open/forms/components/form-components/FormSecurityAccess.vue +++ b/client/components/open/forms/components/form-components/FormSecurityAccess.vue @@ -72,7 +72,7 @@

Protect your form, and your sensitive files.

-
+
const workingFormStore = useWorkingFormStore() const { content: form } = storeToRefs(workingFormStore) +const config = useRuntimeConfig() -const captchaOptions = [ - { name: 'reCAPTCHA', value: 'recaptcha' }, - { name: 'hCaptcha', value: 'hcaptcha' }, -] +const hasCaptchaProviders = computed(() => { + return config.public.hCaptchaSiteKey || config.public.recaptchaSiteKey +}) + +const captchaOptions = computed(() => { + const options = [] + + if (config.public.recaptchaSiteKey) { + options.push({ name: 'reCAPTCHA', value: 'recaptcha' }) + } + + if (config.public.hCaptchaSiteKey) { + options.push({ name: 'hCaptcha', value: 'hcaptcha' }) + } + + return options +})