Class: Authenticate::PasswordsController
- Inherits:
-
AuthenticateController
- Object
- ApplicationController
- AuthenticateController
- Authenticate::PasswordsController
- Defined in:
- app/controllers/authenticate/passwords_controller.rb
Overview
Request password change via an emailed link with a unique token. Thanks to devise and Clearance.
Instance Method Summary collapse
-
#create ⇒ Object
Send password change email.
-
#edit ⇒ Object
Screen to enter your new password.
-
#new ⇒ Object
Display screen to request a password change email.
-
#update ⇒ Object
Save the new password entered in #edit.
Instance Method Details
#create ⇒ Object
Send password change email.
POST /users/password
16 17 18 19 20 21 22 |
# File 'app/controllers/authenticate/passwords_controller.rb', line 16 def create if (user = find_user_for_create) user.forgot_password! deliver_email(user) end redirect_to sign_in_path, notice: flash_create_description end |
#edit ⇒ Object
Screen to enter your new password.
GET /users/passwords/3/edit?token=abcdef
27 28 29 30 31 32 33 34 |
# File 'app/controllers/authenticate/passwords_controller.rb', line 27 def edit @user = find_user_for_edit if !@user.reset_password_period_valid? redirect_to sign_in_path, notice: flash_failure_token_expired else render template: 'passwords/edit' end end |
#new ⇒ Object
Display screen to request a password change email. GET /users/passwords/new
9 10 11 |
# File 'app/controllers/authenticate/passwords_controller.rb', line 9 def new render template: 'passwords/new' end |
#update ⇒ Object
Save the new password entered in #edit.
PUT /users/passwords/3/
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/authenticate/passwords_controller.rb', line 39 def update @user = find_user_for_update if !@user.reset_password_period_valid? redirect_to sign_in_path, notice: flash_failure_token_expired elsif @user.update_password password_reset_params # password changed, log user back in! login @user redirect_to url_after_update, notice: flash_success_password_changed else # failed to update password for some reason, perhaps password was too short or otherwise sucked. flash.now[:notice] = flash_failure_after_update render template: 'passwords/edit' end end |