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

Custom questions not working

arivarasanl opened this issue · comments

acts_as_textcaptcha is working fine for me.

If I add custom questions in my model by,
acts_as_textcaptcha :api_key => my_key',
:bcrypt_salt => 'salt',
:bcrypt_cost => '3',
:questions => [{ 'question' => '1+1', 'answers' => '2,two' },
{ 'question' => 'The green hat is what color?', 'answers' => 'green' }]

or
If I add question in config/textcaptcha.yml

it is not showing my custom questions, instead it shows the random question.

It shows my custom question if I edit the :api_key value,
example: my 32digit api_key ends with 8 and i changed the last digit from 8 to 9. Now its is working.

Will it cause any issue in future if change the api_key value?
or
How can I show my custom questions without editing the api_key value?

Thanks,
Arivarasan L

By default acts_as_textcaptcha will always prioritise fetching random questions from the Textcaptcha API if a valid api_key is specified. If the API call fails (e.g. an invalid key) or is not present, then the gem will use you're custom questions (first from the hash in the acts_as_textcaptcha if present, or if not from the yml file)

I'm not sure what you want to happen besides this? Are you looking for a mix of random questions from the API and your'e own defined questions? I'm not sure how useful that would be...

Thanks for the reply.

Now i understand the flow. I want to display my own defined question.
So I generate the yml file and removed the api_key.
Now everything works fine..

Thanks,

Arivarasan L