mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-25 01:03:18 +08:00
Added option to override default OTP drift time [SCI-6027] (#3507)
This commit is contained in:
parent
a847f68de4
commit
295d27f0d7
1 changed files with 6 additions and 1 deletions
|
@ -47,6 +47,8 @@ class User < ApplicationRecord
|
|||
}
|
||||
}.freeze
|
||||
|
||||
DEFAULT_OTP_DRIFT_TIME_SECONDS = 10
|
||||
|
||||
store_accessor :variables, :export_vars
|
||||
|
||||
default_variables(
|
||||
|
@ -621,7 +623,10 @@ class User < ApplicationRecord
|
|||
raise StandardError, 'Missing otp_secret' unless otp_secret
|
||||
|
||||
totp = ROTP::TOTP.new(otp_secret, issuer: 'sciNote')
|
||||
totp.verify(otp, drift_behind: 10)
|
||||
totp.verify(
|
||||
otp,
|
||||
drift_behind: ENV.fetch('OTP_DRIFT_TIME_SECONDS', DEFAULT_OTP_DRIFT_TIME_SECONDS).to_i
|
||||
)
|
||||
end
|
||||
|
||||
def assign_2fa_token!
|
||||
|
|
Loading…
Reference in a new issue