From 08ab3398c79b516674e63e855ad1d62c91070e06 Mon Sep 17 00:00:00 2001 From: Jakub Kuchar Date: Fri, 25 Sep 2020 14:03:27 +0200 Subject: [PATCH 1/3] Update helpers.rb --- lib/two_factor_authentication/controllers/helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/two_factor_authentication/controllers/helpers.rb b/lib/two_factor_authentication/controllers/helpers.rb index 64e8377c..87a03d74 100644 --- a/lib/two_factor_authentication/controllers/helpers.rb +++ b/lib/two_factor_authentication/controllers/helpers.rb @@ -12,7 +12,7 @@ module Helpers def handle_two_factor_authentication unless devise_controller? Devise.mappings.keys.flatten.any? do |scope| - if signed_in?(scope) and warden.session(scope)[TwoFactorAuthentication::NEED_AUTHENTICATION] + if signed_in?(scope) and warden.session(scope)[::TwoFactorAuthentication::NEED_AUTHENTICATION] handle_failed_second_factor(scope) end end From 8b55c1f2745c4179447977fc1a691bee177dfb98 Mon Sep 17 00:00:00 2001 From: Jakub Kuchar Date: Fri, 25 Sep 2020 14:05:41 +0200 Subject: [PATCH 2/3] Update helpers.rb --- lib/two_factor_authentication/controllers/helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/two_factor_authentication/controllers/helpers.rb b/lib/two_factor_authentication/controllers/helpers.rb index 87a03d74..9400b4c8 100644 --- a/lib/two_factor_authentication/controllers/helpers.rb +++ b/lib/two_factor_authentication/controllers/helpers.rb @@ -47,7 +47,7 @@ module Devise module Controllers module Helpers def is_fully_authenticated? - !session["warden.user.user.session"].try(:[], TwoFactorAuthentication::NEED_AUTHENTICATION) + !session["warden.user.user.session"].try(:[], ::TwoFactorAuthentication::NEED_AUTHENTICATION) end end end From f6f385cb87662f315c94f84658676d334e9747f9 Mon Sep 17 00:00:00 2001 From: Jakub Kuchar Date: Wed, 5 May 2021 14:27:48 +0200 Subject: [PATCH 3/3] rails 6.1 update in favor of update_attributes --- .../models/two_factor_authenticatable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/two_factor_authentication/models/two_factor_authenticatable.rb b/lib/two_factor_authentication/models/two_factor_authenticatable.rb index 6d73a0fb..d23cae87 100644 --- a/lib/two_factor_authentication/models/two_factor_authenticatable.rb +++ b/lib/two_factor_authentication/models/two_factor_authenticatable.rb @@ -101,7 +101,7 @@ def generate_totp_secret def create_direct_otp(options = {}) # Create a new random OTP and store it in the database digits = options[:length] || self.class.direct_otp_length || 6 - update_attributes( + update( direct_otp: random_base10(digits), direct_otp_sent_at: Time.now.utc ) @@ -122,7 +122,7 @@ def direct_otp_expired? end def clear_direct_otp - update_attributes(direct_otp: nil, direct_otp_sent_at: nil) + update(direct_otp: nil, direct_otp_sent_at: nil) end end