class TwoFactorDevices::Devices::Validator

logic for device confirmation Allow to generate otp code challenge and validate received code

Constants

DEFAULT_CONFIRMATION_DRIFT

Public Instance Methods

make_challenge(device) click to toggle source
# File lib/two_factor_devices/devices/validator.rb, line 10
def make_challenge(device)
  Gateway.send_otp(device, totp.now)
end
totp() click to toggle source
# File lib/two_factor_devices/devices/validator.rb, line 18
def totp
  @totp ||= ROTP::TOTP.new(TwoFactorDevices.otp_base_secret)
end
validate(code) click to toggle source
# File lib/two_factor_devices/devices/validator.rb, line 14
def validate(code)
  totp.verify(code, drift_behind: DEFAULT_CONFIRMATION_DRIFT)
end