Add helper method for checking user 2fa enabled [SCI-10634]

This commit is contained in:
wandji20 2024-04-18 10:43:07 +01:00
parent 80aa14566d
commit be093c9302

View file

@ -21,7 +21,7 @@ class Users::PasswordsController < Devise::PasswordsController
if resource.errors.blank? if resource.errors.blank?
resource.unlock_access! if unlockable?(resource) resource.unlock_access! if unlockable?(resource)
if !resource.two_factor_auth_enabled? if !two_factor_auth_enabled_for(resource)
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
set_flash_message!(:notice, flash_message) set_flash_message!(:notice, flash_message)
resource.after_database_authentication resource.after_database_authentication
@ -39,7 +39,11 @@ class Users::PasswordsController < Devise::PasswordsController
protected protected
def after_resetting_password_path_for(resource) def after_resetting_password_path_for(resource)
resource.two_factor_auth_enabled? ? new_session_path(resource_name) : after_sign_in_path_for(resource) two_factor_auth_enabled_for(resource) ? new_session_path(resource_name) : after_sign_in_path_for(resource)
end
def two_factor_auth_enabled_for(user)
user.two_factor_auth_enabled?
end end
# The path used after sending reset password instructions # The path used after sending reset password instructions