|
|
@ -20,17 +20,15 @@ module Devise |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
::Devise::Models.config(self, :max_login_attempts) |
|
|
|
::Devise::Models.config(self, :max_login_attempts, :allowed_otp_drift_seconds) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
module InstanceMethodsOnActivation |
|
|
|
module InstanceMethodsOnActivation |
|
|
|
def authenticate_otp(code, options = {}) |
|
|
|
def authenticate_otp(code, options = {}) |
|
|
|
totp = ROTP::TOTP.new(self.otp_column) |
|
|
|
totp = ROTP::TOTP.new(self.otp_column) |
|
|
|
if drift = options[:drift] |
|
|
|
drift = options[:drift] || self.class.allowed_otp_drift_seconds |
|
|
|
totp.verify_with_drift(code, drift) |
|
|
|
|
|
|
|
else |
|
|
|
totp.verify_with_drift(code, drift) |
|
|
|
totp.verify(code) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def otp_code(time = Time.now) |
|
|
|
def otp_code(time = Time.now) |
|
|
|