Sha256: bcd084ec6b1056cd26cd7eeabc23397784ad9e4d2ea978d37c492d3bc8f081d4

Contents?: true

Size: 650 Bytes

Versions: 9

Compression:

Stored size: 650 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_grant_type(client)
        if code = client.authorization_codes.find_by_token(params[:code])
          success! code.user
        else
          oauth_error! :invalid_grant, I18n.t('devise.failure.invalid_auth_code')
        end
      end
    end
  end
end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
brycesch-devise_oauth2_providable-1.2.8 lib/devise/oauth2_providable/strategies/oauth2_authorization_code_grant_type_strategy.rb
brycesch-devise_oauth2_providable-1.2.7 lib/devise/oauth2_providable/strategies/oauth2_authorization_code_grant_type_strategy.rb
brycesch-devise_oauth2_providable-1.2.6 lib/devise/oauth2_providable/strategies/oauth2_authorization_code_grant_type_strategy.rb
brycesch-devise_oauth2_providable-1.2.5 lib/devise/oauth2_providable/strategies/oauth2_authorization_code_grant_type_strategy.rb
brycesch-devise_oauth2_providable-1.2.4 lib/devise/oauth2_providable/strategies/oauth2_authorization_code_grant_type_strategy.rb
brycesch-devise_oauth2_providable-1.2.3 lib/devise/oauth2_providable/strategies/oauth2_authorization_code_grant_type_strategy.rb
brycesch-devise_oauth2_providable-1.2.2 lib/devise/oauth2_providable/strategies/oauth2_authorization_code_grant_type_strategy.rb
brycesch-devise_oauth2_providable-1.2.1 lib/devise/oauth2_providable/strategies/oauth2_authorization_code_grant_type_strategy.rb
brycesch-devise_oauth2_providable-1.2.0 lib/devise/oauth2_providable/strategies/oauth2_authorization_code_grant_type_strategy.rb