Rails 3.0 Devise reset Password, answering a question

I am using a device with rails 3. In the user model, I created fields for the question and the answer to this question.

I want to know how I can implement a forget password in the following logic:

  • On the page with the password "forget password", the user enters the username
  • In the next step, the application should display the question stored in db.
  • The user answers the question, and the application matches the answer if the answer matches the values ​​stored in db.
  • It redirects the password editing page where the password can be updated.

I tried to override the controller password but got stuck.

Thanks for the help in advance.

Note: I am new to rails and my first project

+3
source share
3 answers

I have not used Devise before, however, assuming you have a befor_filter on your controller for routing for authentication, you can do something like:

skip_before_filter :authenticate_with_devise if user_answered_question_correctly?
0
source

this stone has a security_questionable function that could do the trick, among other things https://github.com/phatworx/devise_security_extension

0
source

Devise.

  • forget_password:

routes.rb:

get "forgot_password" => "passwords#forgot"
get "forgot_password/verify_question" => "passwords#verify_question"
post "forgot_password/verify_answer" => "passwords#verify_answer"
post "forgot_password/reset_password" => "passwords#reset"
  1. app/controller/passwords_controller.rb , /.
  2. .
  3. forgot password .
  4. Profit
0

Source: https://habr.com/ru/post/1787956/


All Articles