passwords_controller.rb 761 B

12345678910111213141516171819202122232425262728293031
  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. resource.session_activations.destroy_all if resource.errors.empty?
  9. end
  10. end
  11. private
  12. def check_validity_of_reset_password_token
  13. unless reset_password_token_is_valid?
  14. flash[:error] = I18n.t('auth.invalid_reset_password_token')
  15. redirect_to new_password_path(resource_name)
  16. end
  17. end
  18. def set_body_classes
  19. @body_classes = 'lighter'
  20. end
  21. def reset_password_token_is_valid?
  22. resource_class.with_reset_password_token(params[:reset_password_token]).present?
  23. end
  24. end