Merge pull request #3289 from biosistemika/SCI-5698-fix-force-2fa

SCI-5698 fix force 2fa
This commit is contained in:
Miha Mencin 2021-05-10 10:47:49 +02:00 committed by GitHub
commit 1c20c02686
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,7 +22,7 @@ class Users::SessionsController < Devise::SessionsController
# POST /resource/sign_in
def create
super do |user|
if user.two_factor_auth_enabled? && !bypass_two_factor_auth?
if redirect_to_two_factor_auth?(user)
sign_out
session[:otp_user_id] = user.id
store_location_for(:user, request.original_fullpath) if request.get?
@ -114,4 +114,8 @@ class Users::SessionsController < Devise::SessionsController
def bypass_two_factor_auth?
false
end
def redirect_to_two_factor_auth?(user)
user.two_factor_auth_enabled? && !bypass_two_factor_auth?
end
end