app/lib/multifactor_authenticator.rb
# Returns true/false and burns the login_code if it is accepted,
# returns false if not enabled for the user.
Returns true/false and burns the login_code if it is accepted,
returns false if not enabled for the user.
Returns true / false and burns the login_code if it is accepted returns false if not enabled for the user .
def is_multifactor_code_valid?(login_code)
    return false unless is_multifactor_enabled?
    totp = create_totp!
    verified_password_timestamp = totp.verify(login_code, {
      after: multifactor_config.last_verification_at,
      drift_behind: 15
    })
    return false if verified_password_timestamp.nil?
    multifactor_config.reload.update!(last_verification_at: Time.at(verified_password_timestamp))
    true
  end
def is_multifactor_code_valid? ( login_code ) return false unless is_multifactor_enabled? totp = create_totp! verified_password_timestamp = totp . verify ( login_code , { after : multifactor_config . last_verification_at , drift_behind : 15 } ) return false if verified_password_timestamp . nil? multifactor_config . reload . update! ( last_verification_at : Time . at ( verified_password_timestamp ) ) true end
Returns true/false and burns the login_code if it is accepted,
returns false if not enabled for the user.
Returns true / false and burns the login_code if it is accepted returns false if not enabled for the user .
# Check the code, enforcing that it comes after the last verification, but # allowing 15 seconds of drift if the code hasn't been used yet. # If we authenticated the user, burn the login_code for this time window
login_code
<not_specific>