Class: DuoSecurity::Attempt

Inherits:
Object
  • Object
show all
Defined in:
lib/duo_security/attempt.rb

Instance Method Summary collapse

Constructor Details

#initialize(api, username) ⇒ Attempt

Returns a new instance of Attempt.



3
4
5
6
# File 'lib/duo_security/attempt.rb', line 3

def initialize(api, username)
  @api      = api
  @username = username
end

Instance Method Details

#login!Object



8
9
10
11
12
13
14
15
# File 'lib/duo_security/attempt.rb', line 8

def login!
  preauth = @api.preauth(@username)
  factor  = preauth["factors"].fetch("default")
  
  @api.auth(@username, "auto", {"auto" => factor})
rescue API::UnknownUser => e
  false
end