passwords_controller.rb 728 B

1234567891011121314151617181920212223242526272829
  1. # frozen_string_literal: true
  2. class Auth::PasswordsController < Devise::PasswordsController
  3. skip_before_action :check_self_destruct!
  4. before_action :redirect_invalid_reset_token, only: :edit, unless: :reset_password_token_is_valid?
  5. layout 'auth'
  6. def update
  7. super do |resource|
  8. if resource.errors.empty?
  9. resource.session_activations.destroy_all
  10. resource.revoke_access!
  11. end
  12. end
  13. end
  14. private
  15. def redirect_invalid_reset_token
  16. flash[:error] = I18n.t('auth.invalid_reset_password_token')
  17. redirect_to new_password_path(resource_name)
  18. end
  19. def reset_password_token_is_valid?
  20. resource_class.with_reset_password_token(params[:reset_password_token]).present?
  21. end
  22. end