Sha256: 880ce58510c79c68d1e02704c7280ec8f5f471c60f90d4514216334a73bc70c8

Contents?: true

Size: 667 Bytes

Versions: 8

Compression:

Stored size: 667 Bytes

Contents

require 'devise/strategies/base'

module Devise
  module Strategies
    class Oauth2Providable < Base
      def valid?
        env[Rack::OAuth2::Server::Resource::ACCESS_TOKEN].present?
      end
      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
    end
  end
end

Warden::Strategies.add(:oauth2_providable, Devise::Strategies::Oauth2Providable)

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
devise_oauth2_providable-0.2.0 lib/devise_oauth2_providable/strategy.rb
devise_oauth2_providable-0.1.6 lib/devise_oauth2_providable/strategy.rb
devise_oauth2_providable-0.1.5 lib/devise_oauth2_providable/strategy.rb
devise_oauth2_providable-0.1.4 lib/devise_oauth2_providable/strategy.rb
devise_oauth2_providable-0.1.3 lib/devise_oauth2_providable/strategy.rb
devise_oauth2_providable-0.1.2 lib/devise_oauth2_providable/strategy.rb
devise_oauth2_providable-0.1.1 lib/devise_oauth2_providable/strategy.rb
devise_oauth2_providable-0.1.0 lib/devise_oauth2_providable/strategy.rb