Class: Devise::Strategies::Oauth2TokenBearerAuthenticatable

Inherits:
Base
  • Object
show all
Defined in:
lib/devise_oauth2_token_bearer_authenticatable/strategy.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object

Raises:

  • (Rack::OAuth2::Server::Resource::Bearer::Unauthorized)


9
10
11
12
13
14
# File 'lib/devise_oauth2_token_bearer_authenticatable/strategy.rb', line 9

def authenticate!
  token = AccessToken.valid.find_by_token env[Rack::OAuth2::Server::Resource::ACCESS_TOKEN]
  raise Rack::OAuth2::Server::Resource::Bearer::Unauthorized unless token
  raise Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new(:invalid_token, 'User token is required') unless token.user
  success! token.user
end

#valid?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/devise_oauth2_token_bearer_authenticatable/strategy.rb', line 6

def valid?
  env[Rack::OAuth2::Server::Resource::ACCESS_TOKEN].present?
end