Skip to content

Commit e5f93cd

Browse files
patch capacha
Signed-off-by: Dipankar Das <[email protected]>
1 parent f0f5cea commit e5f93cd

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/components/AppFooter.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ const isProduction = import.meta.env.PROD;
146146
<div class="form__entry entry_block">
147147
<div class="form__label-row">
148148
<div class="cf-turnstile sib-visible-recaptcha" id="sib-captcha" data-sitekey="0x4AAAAAACEW9pOFvA0Drq8K" data-callback="handleCaptchaResponse"></div>
149+
<input type="hidden" id="g-recaptcha-response" name="g-recaptcha-response" class="sib-captcha-token" data-required="true" />
149150
</div>
150151
<label class="entry__error entry__error--primary" style="font-size:14px; text-align:left; font-family:'Inter', Helvetica, sans-serif; display:none;"></label>
151152
</div>

src/layouts/Layout.astro

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,26 @@ const { title = "ksctl - Strive towards Fast, Efficient and Sustainable Computin
184184
// Turnstile/reCAPTCHA callback function
185185
window.handleCaptchaResponse = function(token) {
186186
console.log('Captcha completed:', token);
187+
188+
// Set the token in the hidden input field that Brevo expects
189+
var tokenInput = document.getElementById('g-recaptcha-response');
190+
if (tokenInput) {
191+
tokenInput.value = token;
192+
}
193+
194+
// Trigger the captchaChange event for Brevo
187195
var event = new Event('captchaChange');
188196
var captchaElement = document.getElementById('sib-captcha');
189197
if (captchaElement) {
190-
// Store the token for Brevo form validation
191198
captchaElement.dataset.captchaToken = token;
192199
captchaElement.dispatchEvent(event);
193200
}
201+
202+
// Also dispatch input event on the hidden field
203+
if (tokenInput) {
204+
var inputEvent = new Event('input', { bubbles: true });
205+
tokenInput.dispatchEvent(inputEvent);
206+
}
194207
};
195208

196209
// Brevo form configuration (must be set before main.js loads)

0 commit comments

Comments
 (0)