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
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="showCaptcha">
|
||||
<div v-if="showCaptcha && isSiteKeyAvailable">
|
||||
<RecaptchaV2
|
||||
v-if="provider === 'recaptcha'"
|
||||
:key="`recaptcha-${componentKey}`"
|
||||
@@ -68,6 +68,15 @@ const componentKey = ref(0)
|
||||
|
||||
const formFieldName = computed(() => props.provider === 'recaptcha' ? 'g-recaptcha-response' : 'h-captcha-response')
|
||||
|
||||
const isSiteKeyAvailable = computed(() => {
|
||||
if (props.provider === 'recaptcha') {
|
||||
return !!recaptchaSiteKey
|
||||
} else if (props.provider === 'hcaptcha') {
|
||||
return !!hCaptchaSiteKey
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
// Watch for provider changes to reset the form field
|
||||
watch(() => props.provider, async (newProvider, oldProvider) => {
|
||||
if (newProvider !== oldProvider) {
|
||||
|
||||
Reference in New Issue
Block a user