lib/devise_two_factor/models/two_factor_authenticatable.rb
# This defaults to the model's otp_secret
# If this hasn't been generated yet, pass a secret as an option
This defaults to the model's otp_secret
If this hasn't been generated yet, pass a secret as an option
This defaults to the model ' s otp_secret If this hasn ' t been generated yet pass a secret as an option
def validate_and_consume_otp!(code, options = {})
        otp_secret = options[:otp_secret] || self.otp_secret
        return false unless code.present? && otp_secret.present?
        totp = otp(otp_secret)
        if totp.verify(code.gsub(/\s+/, ""), drift_behind: self.class.otp_allowed_drift, drift_ahead: self.class.otp_allowed_drift)
          return consume_otp!
        end
        false
      end
def validate_and_consume_otp! ( code , options = { } ) otp_secret = options [ :otp_secret ] || self . otp_secret return false unless code . present? && otp_secret . present? totp = otp ( otp_secret ) if totp . verify ( code . gsub ( / \s + / , "" ) , drift_behind : self . class . otp_allowed_drift , drift_ahead : self . class . otp_allowed_drift ) return consume_otp! end false end
This defaults to the model's otp_secret
If this hasn't been generated yet, pass a secret as an option
This defaults to the model ' s otp_secret If this hasn ' t been generated yet pass a secret as an option
code
<not_specific>
options
<not_specific>