Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recaptcha_failure_reason for enchanced error reporting #459

Merged
merged 2 commits into from
Dec 8, 2024

Conversation

holli
Copy link
Contributor

@holli holli commented Dec 8, 2024

This update introduces the recaptcha_failure_reason method to provide developers with detailed information on common verification failures. This enhancement aims to improve debugging and error handling when integrating to applications.

I had annoying moments debugging errors when using the gem. Gem itself worked nicely but the error messages needed some manual work. E.g. when custom javascripts set the request parameter correctly but with wrong name, the gem didn't give any errors it just failed. I wanted to have simpler error messages. This also helps when logging the results as now I have single method to return some information.

Key Changes:

  • Added recaptcha_failure_reason method in controller_methods.rb to return detailed failure reasons.
  • Updated verify_recaptcha method to set @_recaptcha_failure_reason with specific error messages based on the verification outcome.
  • Modified verify_recaptcha! to raise VerifyError with an informative error message.
  • Updated tests in test/verify_test.rb to cover new failure scenarios and ensure recaptcha_failure_reason provides accurate information.

Pre-Merge Checklist

  • CHANGELOG.md updated with short summary for user facing changes

Copy link
Collaborator

@grosser grosser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is super nice, thx!

@grosser grosser merged commit cc575f3 into ambethia:master Dec 8, 2024
@grosser
Copy link
Collaborator

grosser commented Dec 8, 2024

5.18.0

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.

2 participants