Sha256: b67728f63bda556acb5ab92ef16c78478618e6849bd289718a71a554db306b2a

Contents?: true

Size: 727 Bytes

Versions: 7

Compression:

Stored size: 727 Bytes

Contents

require 'devise/oauth2_providable/strategies/oauth2_grant_type_strategy'

module Devise
  module Strategies
    class Oauth2PasswordGrantTypeStrategy < Oauth2GrantTypeStrategy
      def grant_type
        'password'
      end

      def authenticate_grant_type(client)
        resource = mapping.to.find_for_authentication(mapping.to.authentication_keys.first => params[:username])
        if validate(resource) { resource.valid_password?(params[:password]) }
          success! resource
        else
          oauth_error! :invalid_grant, 'invalid password authentication request'
        end
      end
    end
  end
end

Warden::Strategies.add(:oauth2_password_grantable, Devise::Strategies::Oauth2PasswordGrantTypeStrategy)

Version data entries

7 entries across 7 versions & 4 rubygems

Version Path
devise_oauth2_rails4-1.1.2 lib/devise/oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb
mustwin_devise_oauth2_providable-1.1.6 lib/devise/oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb
mustwin_devise_oauth2_providable-1.1.5 lib/devise/oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb
mustwin_devise_oauth2_providable-1.1.4 lib/devise/oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb
mustwin_devise_oauth2_providable-1.1.3 lib/devise/oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb
insrc_devise_oauth2_providable-1.1.2 lib/devise/oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb
devise_oauth2_providable-1.1.2 lib/devise/oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb