Class: Devise::Strategies::TokenAuthenticatable

Inherits:
Authenticatable
  • Object
show all
Defined in:
lib/devise/strategies/token_authenticatable.rb

Overview

Strategy for signing in a user, based on a authenticatable token. This works for both params and http. For the former, all you need to do is to pass the params in the URL:

http://myapp.example.com/?user_token=SECRET

For HTTP, you can pass the token as username and blank password. Since some clients may require a password, you can pass “X” as password and it will simply be ignored.

Instance Attribute Summary

Attributes inherited from Authenticatable

#authentication_hash, #password

Instance Method Summary collapse

Methods inherited from Authenticatable

#valid?

Methods inherited from Base

#mapping

Instance Method Details

#authenticate!Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/devise/strategies/token_authenticatable.rb', line 17

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

  if validate(resource)
    resource.after_token_authentication
    success!(resource)
  elsif !halted?
    fail(:invalid_token)
  end
end

#store?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/devise/strategies/token_authenticatable.rb', line 13

def store?
  !mapping.to.stateless_token
end