class TfaSession

Form object for handling two-factor authentication sessions

Automatically generated by the orthodox gem (github.com/katanacode/orthodox) © Copyright 2019 Katana Code Ltd. All Rights Reserved.

Constants

OTP_FORMAT

Regex for OTP format

RECOVERY_CODE_FORMAT

Regex for recovery code format

Public Instance Methods

otp?() click to toggle source

Public instance methods =

# File lib/generators/authentication/templates/models/tfa_session.rb, line 51
def otp?
  otp.present?
end
recovery_code?() click to toggle source
# File lib/generators/authentication/templates/models/tfa_session.rb, line 55
def recovery_code?
  recovery_code.present?
end

Private Instance Methods

otp_correct() click to toggle source

Private instance methods =

# File lib/generators/authentication/templates/models/tfa_session.rb, line 65
def otp_correct
  unless record.valid_otp?(otp.to_s)
    errors.add(:base, "OTP code was not correct")
  end
end
recovery_code_correct() click to toggle source
# File lib/generators/authentication/templates/models/tfa_session.rb, line 71
def recovery_code_correct
  unless record.valid_recovery_code?(recovery_code.to_s)
    errors.add(:base, "Recovery code was not correct")
  end    
end