diff --git a/lib/two_factor_authentication/controllers/helpers.rb b/lib/two_factor_authentication/controllers/helpers.rb index 64e8377c..9400b4c8 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 @@ -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 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