Class: Mori::PasswordsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- Mori::PasswordsController
- Defined in:
- app/controllers/mori/passwords_controller.rb
Overview
Mori::PasswordsController is responsible for changing and resetting passwords
Instance Method Summary collapse
- #change ⇒ Object
- #forgot ⇒ Object
- #password_change_conditions ⇒ Object
- #reset ⇒ Object
- #reset_password ⇒ Object
- #send_reset ⇒ Object
- #update ⇒ Object
Methods inherited from BaseController
Instance Method Details
#change ⇒ Object
13 14 15 16 |
# File 'app/controllers/mori/passwords_controller.rb', line 13 def change # View for change password render :template => 'passwords/change' end |
#forgot ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'app/controllers/mori/passwords_controller.rb', line 4 def forgot # View for sending password reset if current_user redirect_to @config.dashboard_path else render :template => 'passwords/forgot' end end |
#password_change_conditions ⇒ Object
61 62 63 |
# File 'app/controllers/mori/passwords_controller.rb', line 61 def password_change_conditions current_user.authenticate(params[:password]) && params[:new_password] == params[:new_password_confirmation] end |
#reset ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/controllers/mori/passwords_controller.rb', line 18 def reset @user = @config.user_model.find_by_password_reset_token(@token) unless @token.blank? if @user render :template => 'passwords/reset' else redirect_to root_path end end |
#reset_password ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/mori/passwords_controller.rb', line 49 def reset_password user = @config.user_model.find_by_password_reset_token @token if @token != user.password_reset_token or user.password_reset_sent < Mori::Token.expiration_date flash[:notice] = t('flashes.invalid_password_reset_token') redirect_to "/passwords/reset?token=#{@token}" else user.reset_password(params[:new_password]) warden.authenticate! redirect_to @config.dashboard_path end end |
#send_reset ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/mori/passwords_controller.rb', line 27 def send_reset # Send Password Reset to User if user = @config.user_model.find_by_normalized_email(params[:email]) user.forgot_password render :template => 'passwords/send_reset' else render :template => 'passwords/forgot' end end |
#update ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/mori/passwords_controller.rb', line 37 def update # Update their password if password_change_conditions current_user.change_password(params[:new_password]) flash[:notice] = t('flashes.password_changed_successfully') redirect_to @config.dashboard_path else flash[:notice] = I18n.t('flashes.password_change_failed') render :template => 'passwords/change' end end |