passwords_controller.rb 855 B

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