From 6cca4fe5efd45c0093f52beb4ea0f7df39a7a16a Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 10 Mar 2022 08:37:05 +0000 Subject: [PATCH] Set condition based on class having the 2fa module rather than hardcoding class name --- app/controllers/auth/passwords_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/auth/passwords_controller.rb b/app/controllers/auth/passwords_controller.rb index ebdde1606..acbe63e07 100644 --- a/app/controllers/auth/passwords_controller.rb +++ b/app/controllers/auth/passwords_controller.rb @@ -51,7 +51,8 @@ class Auth::PasswordsController < Devise::PasswordsController protected def set_2fa_required - return unless resource_class == AdminUser + return unless resource.respond_to?(:need_two_factor_authentication?) && + resource.need_two_factor_authentication?(request) warden.session(resource_class.name.underscore)[TwoFactorAuthentication::NEED_AUTHENTICATION] = true end