Sha256: d221b215ecca2a53d946c43536c2257edbe97db19fca4848f5d7a0dc500ae6a8

Contents?: true

Size: 652 Bytes

Versions: 3

Compression:

Stored size: 652 Bytes

Contents

require 'devise/oauth2_providable/strategies/oauth2_grant_type_strategy'

module Devise
  module Strategies
    class Oauth2AuthorizationCodeGrantTypeStrategy < Oauth2GrantTypeStrategy
      def grant_type
        'authorization_code'
      end

      def authenticate!
        if client && code = client.authorization_codes.valid.find_by_token(params[:code])
          success! code.user
        elsif !halted?
          oauth_error! :invalid_grant, 'invalid authorization code request'
        end
      end
    end
  end
end

Warden::Strategies.add(:oauth2_authorization_code_grantable, Devise::Strategies::Oauth2AuthorizationCodeGrantTypeStrategy)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
devise_oauth2_providable-1.0.1 lib/devise/oauth2_providable/strategies/oauth2_authorization_code_grant_type_strategy.rb
devise_oauth2_providable-1.0.0 lib/devise/oauth2_providable/strategies/oauth2_authorization_code_grant_type_strategy.rb
devise_oauth2_providable-1.0.0.beta1 lib/devise/oauth2_providable/strategies/oauth2_authorization_code_grant_type_strategy.rb