Class: RailsSimpleAuth::PasswordsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- RailsSimpleAuth::PasswordsController
- Defined in:
- app/controllers/rails_simple_auth/passwords_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/rails_simple_auth/passwords_controller.rb', line 19 def create user = user_class.find_by(email: params[:email]) if user && can_reset_password?(user) token = user.generate_password_reset_token RailsSimpleAuth.configuration.mailer.password_reset(user, token).deliver_later end redirect_to new_session_path, notice: 'If an account exists with that email, password reset instructions have been sent.' end |
#edit ⇒ Object
17 |
# File 'app/controllers/rails_simple_auth/passwords_controller.rb', line 17 def edit; end |
#new ⇒ Object
15 |
# File 'app/controllers/rails_simple_auth/passwords_controller.rb', line 15 def new; end |
#update ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/rails_simple_auth/passwords_controller.rb', line 31 def update ActiveRecord::Base.transaction do if @user.update(password_params) @user.invalidate_all_sessions! redirect_to new_session_path, notice: 'Password has been reset. Please sign in with your new password.' else render :edit, status: :unprocessable_content raise ActiveRecord::Rollback end end rescue ActiveRecord::StatementInvalid => e Rails.logger.error( "[RailsSimpleAuth] Session invalidation failed after password reset for user #{@user.id}: #{e.}" ) # Password was rolled back due to transaction, redirect with error redirect_to new_password_path, alert: 'Password reset failed. Please try again.' end |