Class: Storefront::Users::PasswordsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Storefront::Users::PasswordsController
- Defined in:
- app/controllers/workarea/storefront/users/passwords_controller.rb
Instance Method Summary collapse
- #change ⇒ Object
- #create ⇒ Object
- #edit ⇒ Object
- #make_change ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
Instance Method Details
#change ⇒ Object
46 47 |
# File 'app/controllers/workarea/storefront/users/passwords_controller.rb', line 46 def change end |
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/workarea/storefront/users/passwords_controller.rb', line 18 def create password_reset = User::PasswordReset.setup!(params[:email]) if password_reset.present? Storefront::AccountMailer.password_reset(password_reset.id.to_s).deliver_later end flash[:success] = t( 'workarea.storefront.flash_messages.password_reset_email_sent', email: params[:email] ) redirect_to forgot_password_path end |
#edit ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'app/controllers/workarea/storefront/users/passwords_controller.rb', line 9 def edit reset = User::PasswordReset.find_by(token: params[:token]) rescue nil unless reset flash[:error] = t('workarea.storefront.flash_messages.password_reset_expired') redirect_to forgot_password_path end end |
#make_change ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/workarea/storefront/users/passwords_controller.rb', line 49 def make_change unless current_user.authenticate(params[:old_password]) flash[:error] = t('workarea.storefront.flash_messages.old_password_invalid') render :change and return end if params[:password].blank? flash[:error] = t('workarea.storefront.flash_messages.password_required') render :change and return end if current_user.update_attributes(password: params[:password]) flash[:success] = t('workarea.storefront.flash_messages.password_reset') redirect_back_or users_account_path else flash[:error] = current_user.errors. render :change and return end end |
#new ⇒ Object
6 7 |
# File 'app/controllers/workarea/storefront/users/passwords_controller.rb', line 6 def new end |
#update ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/workarea/storefront/users/passwords_controller.rb', line 31 def update reset = User::PasswordReset.find_by(token: params[:token]) rescue nil if reset.blank? flash[:error] = t('workarea.storefront.flash_messages.password_reset_expired') render :edit elsif reset.complete(params[:password]) flash[:success] = t('workarea.storefront.flash_messages.password_reset') redirect_to login_path else flash[:error] = reset.errors..to_sentence redirect_to reset_password_path(token: reset.token) end end |