Class: Janus::Strategies::TokenAuthenticatable

Inherits:
Base
  • Object
show all
Defined in:
lib/janus/strategies/token_authenticatable.rb

Instance Attribute Summary

Attributes inherited from Base

#cookies, #manager, #request, #scope, #user

Instance Method Summary collapse

Methods inherited from Base

#auth_method, #initialize, #pass, #resource, #success!, #success?

Constructor Details

This class inherits a constructor from Janus::Strategies::Base

Instance Method Details

#auth_tokenObject



17
18
19
# File 'lib/janus/strategies/token_authenticatable.rb', line 17

def auth_token
  request.params[resource.token_authentication_key]
end

#authenticate!Object



8
9
10
11
12
13
14
15
# File 'lib/janus/strategies/token_authenticatable.rb', line 8

def authenticate!
  user = resource.find_for_token_authentication(auth_token)
  if user
    success!(user)
  else
    pass
  end
end

#valid?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/janus/strategies/token_authenticatable.rb', line 4

def valid?
  resource.include?(Janus::Models::TokenAuthenticatable) and !auth_token.nil?
end