Skip to content

Fix reCAPTCHA v3 on AJAX forms + add it to signup - #108

Merged
WebTigers merged 1 commit into
mainfrom
fix/recaptcha-ajax-forms
Aug 7, 2026
Merged

Fix reCAPTCHA v3 on AJAX forms + add it to signup#108
WebTigers merged 1 commit into
mainfrom
fix/recaptcha-ajax-forms

Conversation

@WebTigers

Copy link
Copy Markdown
Owner

The bug

The v3 helper's submit hook (Tiger_View_Helper_FormRecaptcha::_v3) ran in the capture phase and only preventDefault()'d — it did not stop the form's own AJAX handler, which fired immediately with an empty token, and it never re-armed, so retries reused a spent token. That hard-blocked login / forgot / reset / otp the moment reCAPTCHA was enabled ("your security token expired"). Two lines fix it: stopImmediatePropagation() (hold the AJAX handler until the async token exists) + re-arm per submit. One fix repairs every form-submit AJAX form at once.

Signup

The signup form (public, account-creating) had no reCAPTCHA. It's a button-click AJAX submit (not a native form submit), so it mints the v3 token before the /api call — the same pattern as the shop subscribe form — and validates server-side with Tiger_Validate_Recaptcha. The badge renders via $this->formRecaptcha.

Coverage after this

login / forgot / reset / otp (helper) · signup (here) · shop subscribe (TigerShop). Audited the guest-allowed services — no other guest-facing submit forms exist. No-op when reCAPTCHA is disabled; fail_open covers a Google outage.

Verified

Login confirmed working with reCAPTCHA v3 on dev-com (the helper fix). Unit: FormRecaptcha + the new Hash element test green.

🤖 Generated with Claude Code

The v3 helper's submit hook ran in the capture phase and only preventDefault()'d — it
didn't stop the form's own AJAX handler, which fired instantly with an empty token, and it
never re-armed, so retries reused a spent token. That broke login/forgot/reset/otp the
moment reCAPTCHA was enabled ("your security token expired"). Add stopImmediatePropagation
(hold the AJAX handler until the async token exists) + re-arm per submit. One fix repairs
every form-submit AJAX form at once.

Signup (a public, account-creating form) had NO reCAPTCHA. It's a button-click AJAX submit,
so it mints the v3 token before the /api call (like the shop subscribe form) and validates
server-side with Tiger_Validate_Recaptcha. Renders the badge via $this->formRecaptcha.

Coverage after this: login/forgot/reset/otp (helper) + signup here + shop subscribe.
No other guest-facing submit forms exist. No-op when reCAPTCHA is disabled.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@WebTigers
WebTigers merged commit b7092d5 into main Aug 7, 2026
12 checks passed
@WebTigers
WebTigers deleted the fix/recaptcha-ajax-forms branch August 7, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant