matthutchinson / acts_as_textcaptcha

Text-based logic question captcha's for Rails 🚫🤖

Home Page:https://acts-as-textcaptcha.hiddenloop.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to do the text captcha with just the params

nagaharish opened this issue · comments

Hi,
We have a requirement such that when ever a user wanted to reset password he will just submit the email id and we will send the email instructions to the user.

We wanted to implement the captcha here. Basically we don't even save any data but we wanted to validate the captcha with the parameters received.
Is there a way to do it? If so can you please explain.

Yes, its possible to use the gem to validate a captcha on a non-active record object. The README points to the Contact example in the test suite;

The Contact class is defined and configured here;

(this class hasn't been configured to use the captcha API (it uses direct questions in the config), but you could change that)

And this test shows how that model might be used (calling valid?) will let you check if the captcha is correct.

For your situation, it would probably be best to pass the params to a dedicated Captcha class (similar to the Contact class in this example). Since you probably don't want to put this on User directly, given you are only resetting a password.