Skip to content

Commit

Permalink
Prevent double credential processing on tokens controller for passwor…
Browse files Browse the repository at this point in the history
…d grant types.
  • Loading branch information
Brian Durand committed Aug 22, 2012
1 parent 51c0977 commit d112c59
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions app/controllers/doorkeeper/tokens_controller.rb
Expand Up @@ -23,14 +23,17 @@ def credentials
end

def token
case params[:grant_type]
when 'password'
owner = resource_owner_from_credentials
@token ||= Doorkeeper::OAuth::PasswordAccessTokenRequest.new(client, owner, params)
when 'client_credentials'
@token ||= Doorkeeper::OAuth::ClientCredentialsRequest.new(Doorkeeper.configuration, client, params)
else
@token ||= Doorkeeper::OAuth::AccessTokenRequest.new(client, params)
unless defined?(@token) && @token
case params[:grant_type]
when 'password'
owner = resource_owner_from_credentials
@token = Doorkeeper::OAuth::PasswordAccessTokenRequest.new(client, owner, params)
when 'client_credentials'
@token = Doorkeeper::OAuth::ClientCredentialsRequest.new(Doorkeeper.configuration, client, params)
else
@token = Doorkeeper::OAuth::AccessTokenRequest.new(client, params)
end
end
@token
end
end

0 comments on commit d112c59

Please sign in to comment.