sepiariver / recaptchav2

Google's ReCaptcha V2 + V3 for MODX CMS: https://sepiariver.com/modx/recaptchav2-supports-recaptchav3/
https://sepiariver.com/
GNU General Public License v2.0
21 stars 15 forks source link

Clientside fix for timeout-or-duplicate error #54

Closed Maef closed 3 years ago

Maef commented 3 years ago

When someone submits a form and takes longer then 2 minutes (after entering a webpage) they get an error "timeout-or-duplicate". This error comes from the Google reCaptcha v3 token verification.

There is a topic on Stackoverflow https://stackoverflow.com/questions/55251837/how-to-solve-google-v3-recaptcha-timeout

In order to solve this error we bypass it by changing recaptchav3_html.chunk.tpl. This forces a refresh every 2 minutes. If you have several forms we use the [[+form_id]] to refresh every form.

sepiariver commented 3 years ago

Thank you for your contribution!

There is a guide here https://sepiariver.com/modx/a-guide-to-recaptcha-v3-for-modx-cms/ to address various use cases such as this.

generally speaking with Chunks that are included in packages, they are meant as a guide for the most basic use case

adding the implementation in this PR, while useful, imposes that same implementation on all users as the default. As an example of why this might not be desired is that setting a timeout refreshes the token regardless of whether it will ever be required, whereas someone might desire to trigger it off a user interaction

Please accept my gratitude for your efforts to improve this Extra