You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
807 B

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