Sha256: 98a6ef755210ab6b69d6afc0d271737aeeb585d8659e2cacf1da9be102a51bf6

Contents?: true

Size: 729 Bytes

Versions: 9

Compression:

Stored size: 729 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!
        resource = mapping.to.find_for_authentication(mapping.to.authentication_keys.first => params[:username])
        if client && validate(resource) { resource.valid_password?(params[:password]) }
          success! resource
        elsif !halted?
          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

9 entries across 9 versions & 1 rubygems

Version Path
devise_oauth2_providable-0.3.8 lib/devise_oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb
devise_oauth2_providable-0.3.7 lib/devise_oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb
devise_oauth2_providable-0.3.6 lib/devise_oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb
devise_oauth2_providable-0.3.5 lib/devise_oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb
devise_oauth2_providable-0.3.4 lib/devise_oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb
devise_oauth2_providable-0.3.3 lib/devise_oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb
devise_oauth2_providable-0.3.2 lib/devise_oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb
devise_oauth2_providable-0.3.1 lib/devise_oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb
devise_oauth2_providable-0.3.0 lib/devise_oauth2_providable/strategies/oauth2_password_grant_type_strategy.rb