Skip to content

Commit

Permalink
Merge pull request doorkeeper-gem#142 from bdurand/master
Browse files Browse the repository at this point in the history
Prevent double submission of password based authentication
  • Loading branch information
felipeelias committed Aug 28, 2012
2 parents 1ce9c94 + d112c59 commit 51dc6b7
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 51dc6b7

Please sign in to comment.