From d462080c479825da2fcd27acf38c9dddd0a6ae78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Riveros?= Date: Tue, 27 Nov 2018 14:36:23 -0300 Subject: [PATCH] fix rotp 4 breaking authenticate totp --- .../models/two_factor_authenticatable.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/two_factor_authentication/models/two_factor_authenticatable.rb b/lib/two_factor_authentication/models/two_factor_authenticatable.rb index bd1df46..eb6398c 100644 --- a/lib/two_factor_authentication/models/two_factor_authenticatable.rb +++ b/lib/two_factor_authentication/models/two_factor_authenticatable.rb @@ -39,7 +39,10 @@ module Devise drift = options[:drift] || self.class.allowed_otp_drift_seconds raise "authenticate_totp called with no otp_secret_key set" if totp_secret.nil? totp = ROTP::TOTP.new(totp_secret, digits: digits) - new_timestamp = totp.verify_with_drift_and_prior(without_spaces(code), drift, totp_timestamp) + new_timestamp = totp.verify( + without_spaces(code), + drift_ahead: drift, drift_behind: drift, after: totp_timestamp + ) return false unless new_timestamp self.totp_timestamp = new_timestamp true