Class: DeviseCodeAuthenticatable::Strategies::CodeAuthenticatable

Inherits:
Devise::Strategies::Authenticatable
  • Object
show all
Defined in:
lib/devise_code_authenticatable/strategies/code_authenticatable.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/devise_code_authenticatable/strategies/code_authenticatable.rb', line 7

def authenticate!
  resource = mapping.to.find_for_authentication(authentication_hash)
  hashed = false
   = params[scope].fetch "login_code", ""

  if resource.nil?
    fail(:not_found_in_database)
  else
    if resource..last.expired?
      resource.
      resource.
      fail(:login_code_expired)
    end

    if validate(resource){ hashed = true; resource..last.verify() }
      remember_me(resource)
      resource.after_code_authentication
      success!(resource)
    else
      fail(:invalid_login_code)
    end
  end
end