Class: Devise::Strategies::TokenAuthenticatable

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

Overview

Strategy for signing in a user, based on a authenticatable token. Redirects to sign_in page if it’s not authenticated.

Instance Method Summary collapse

Methods inherited from Base

#mapping

Instance Method Details

#authenticate!Object

Authenticate a user based on authenticatable token params, returning to warden success and the authenticated user if everything is okay. Otherwise redirect to sign in page.



15
16
17
18
19
20
21
# File 'lib/devise/strategies/token_authenticatable.rb', line 15

def authenticate!
  if resource = mapping.to.authenticate_with_token(params[scope] || params)
    success!(resource)
  else
    fail!(:invalid_token)
  end
end

#valid?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/devise/strategies/token_authenticatable.rb', line 8

def valid?
  mapping.to.respond_to?(:authenticate_with_token) && authentication_token(scope).present?
end