Class: Devise::Strategies::TwoFactorBackupable

Inherits:
DatabaseAuthenticatable
  • Object
show all
Defined in:
lib/devise_two_factor/strategies/two_factor_backupable.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/devise_two_factor/strategies/two_factor_backupable.rb', line 5

def authenticate!
  resource = mapping.to.find_for_database_authentication(authentication_hash)

  if validate(resource) { resource.invalidate_otp_backup_code!(params[scope]['otp_attempt']) }
    super
  end

  fail(Devise.paranoid ? :invalid : :not_found_in_database) unless resource

  # We want to cascade to the next strategy if this one fails,
  # but database authenticatable automatically halts on a bad password
  @halted = false if @result == :failure
end