Skip to content

Turn off IP matching by default (setting), fix User Registration AJAX login and Spectra with several forms - #68

Merged
forgetso merged 3 commits into
mainfrom
fix/user-registration-ajax-login-and-spectra
Oct 29, 2026
Merged

forgetso merged 3 commits into
mainfrom
fix/user-registration-ajax-login-and-spectra

Conversation

@forgetso

@forgetso forgetso commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

IP matching: off by default, now a setting

1.23.0 sent the visitor's IP (REMOTE_ADDR) to /siteverify, which turns on IP matching. On sites behind Cloudflare, REMOTE_ADDR is Cloudflare's address, so real visitors could be rejected.

  • New setting: "Visitor IP matching" on the General tab. It's off by default, with these options:
    • On, behind Cloudflare (CF-Connecting-IP)
    • On, behind another proxy (first X-Forwarded-For address)
    • On, direct connection (REMOTE_ADDR)
  • If the chosen header is missing or isn't a valid IP, nothing is sent.
  • Filter change: prosopo/procaptcha/visitor_ip now receives ($ip_from_setting, $remote_addr), where the first value is empty when the setting is off. It can still override the result.
  • Tests: new Pest unit tests cover each source, the default, the filter, and invalid values.
  • Translations: the new strings are translated into de, es, fr, it and pt.

User Registration: AJAX login always failed the captcha check

With "AJAX login" on, ur-login.js posts only its own fields. wp_signon() then runs our wp_authenticate_user check, which never saw procaptcha-response, so every AJAX login was rejected.

  • Fix: a jQuery prefilter adds the token from the login form to action=user_registration_ajax_login_submit requests.
  • Also: user_registration_after_login_failed resets the widget.

Spectra: wrong token when a page has several forms

Spectra reads hidden fields with getElementById('hidden'), which returns the first match on the whole page:

  • a second Spectra form sent the first form's token;

  • a form whose own Spectra hidden field comes first sent no token.

  • Fix: our input no longer has that id. A hidden <span id="prosopo_procaptcha"> lets Spectra's per-form field loop send each form's own value.

Testing

  • tools/check-code-quality.sh passes, including the 7 new unit tests.
  • Spectra: I ran the real forms.min.js (2.20.5) in headless Chrome with two forms. With the old markup, form 2 sent tok-1; with the new markup, each form sent its own token.
  • User Registration: I ran the real ur-login.js (5.3.1) and clicked the AJAX login button. The request now includes procaptcha-response, and a failed login resets the widget.
  • CI: the first two e2e runs on this PR failed a different Beaver Builder "wrong token" test each time, alongside 30+ Failed to fetch errors from the browser to the Procaptcha provider. Reset the captcha after AJAX submissions, public JS events, log failed verifications (1.24.0) #67 had none of those errors. Beaver Builder wasn't changed here, so it looks environmental, but I'm checking it on this run.

🤖 Generated with Claude Code

forgetso and others added 2 commits October 29, 2026 15:08
…lookup with several forms

- User Registration's AJAX login posts only its own fields, so the
  wp_authenticate_user check never saw procaptcha-response and rejected
  every login. A jQuery prefilter now adds the token from the login form,
  and a failed login resets the widget.
- Spectra reads hidden fields via getElementById('hidden'), which returns
  the first match on the page, so a second Spectra form (or one with its
  own hidden field first) sent the wrong or no token. Our input no longer
  has that id; a hidden element whose id is the field name lets Spectra's
  per-form loop send the form's own value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sending `ip` to /siteverify turns on IP matching, which rejects real
visitors when the IP differs from the one that solved the captcha. Most
sites are behind Cloudflare, where REMOTE_ADDR is Cloudflare's address,
so 1.23.0's default could reject legitimate submissions.

- New "Visitor IP matching" select on the General tab, off by default:
  Cloudflare (CF-Connecting-IP), another proxy (first X-Forwarded-For
  address) or a direct connection (REMOTE_ADDR).
- The prosopo/procaptcha/visitor_ip filter now receives the IP from that
  setting (empty when off) plus REMOTE_ADDR, and can still override it.
- Unit tests for each source, the default and the filter.
- Translations for the new strings in de, es, fr, it and pt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@forgetso forgetso changed the title Fix User Registration AJAX login and Spectra with several forms per page Turn off IP matching by default (setting), fix User Registration AJAX login and Spectra with several forms Oct 29, 2026
The widget calls error-callback for failed background requests too (e.g.
the detector bundle or frictionless calls to the provider), which don't
invalidate a token the visitor already has. Clearing our custom input on
those emptied valid tokens in JS-driven forms; CI hit this with Formidable
whenever the provider was unreachable. Expiry and reset still clear it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@forgetso
forgetso merged commit 789fe47 into main Oct 29, 2026
2 of 8 checks passed
@forgetso forgetso mentioned this pull request Oct 29, 2026
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