Automattic / newspack-plugin

An advanced open-source publishing and revenue-generating platform for news organizations.
https://newspack.com
GNU General Public License v2.0
325 stars 49 forks source link

fix(ras-acc): handle recaptcha submit errors #3377

Closed chickenn00dle closed 1 month ago

chickenn00dle commented 1 month ago

All Submissions:

Changes proposed in this Pull Request:

Closes https://app.asana.com/0/1207817176293825/1207878733150051/f

This PR addresses a problem where Firefox could end up with a strange recaptcha connection error and prevent v2 form submissions. This PR addresses this by adding an error callback and forcing a recaptcha refresh when an error is detected.

Screenshot 2024-08-28 at 13 34 57

How to test the changes in this Pull Request:

Be sure to also checkout the following PRs before testing:

  1. As logged out user, try to trigger the connection error (see below note)
  2. Confirm a recaptcha error appears within the auth or checkout modal and not as an alert
  3. Confirm resubmitting the form is successful

Note: This one is a bit tricky to reproduce. I found the best way to get the connection error to appear is to:

  1. Use Firefox
  2. Enable v2 recaptcha
  3. Set recaptcha slider all the way down via Admin console: https://www.google.com/recaptcha/admin
  4. Repeatedly go through the auth registration + checkout flow via a donation block, logout, go through the regular auth registration flow via signin button and repeat a handful of times

But truthfully not sure exactly what causes the issue...

Other information:

chickenn00dle commented 1 month ago

I hope its okay @dkoo, but I've assigned you for review since you have the most context with recaptcha!

dkoo commented 1 month ago

@chickenn00dle I like how simple this fix ended up being. It doesn't necessarily avoid the issue, but it does create a workaround that seemingly works. And it feels like an edge case anyway so hopefully not many users will be affected.