Class: Spina::Admin::PasswordResetsController
- Inherits:
-
AdminController
- Object
- ActionController::Base
- Spina::ApplicationController
- AdminController
- Spina::Admin::PasswordResetsController
- Defined in:
- app/controllers/spina/admin/password_resets_controller.rb
Instance Method Summary collapse
Methods inherited from AdminController
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/spina/admin/password_resets_controller.rb', line 11 def create user = User.find_by(email: params[:email]) if user.present? user.regenerate_password_reset_token user.touch(:password_reset_sent_at) UserMailer.forgot_password(user).deliver_now redirect_to admin_login_path, flash: {success: t('spina.forgot_password.instructions_sent')} else flash.now[:alert] = t('spina.forgot_password.unknown_user') render :new end end |
#edit ⇒ Object
25 26 27 |
# File 'app/controllers/spina/admin/password_resets_controller.rb', line 25 def edit @user = User.find_by!(password_reset_token: params[:id]) end |
#new ⇒ Object
8 9 |
# File 'app/controllers/spina/admin/password_resets_controller.rb', line 8 def new end |
#update ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/spina/admin/password_resets_controller.rb', line 29 def update @user = User.find_by(password_reset_token: params[:id]) if @user.password_reset_sent_at < 2.hours.ago redirect_to new_admin_password_reset_path, flash: {alert: t('spina.forgot_password.expired')} elsif @user.update(user_params) redirect_to admin_login_path, flash: {success: t('spina.forgot_password.success')} else render :edit end end |