correcting param access mistake

This commit is contained in:
Julián Gutiérrez 2016-02-12 18:45:47 +01:00
parent 2f914a0aa3
commit 1f6bb40952

View File

@ -315,16 +315,12 @@ class AuthCodeGrant extends AbstractGrant
ResponseTypeInterface $responseType, ResponseTypeInterface $responseType,
\DateInterval $accessTokenTTL \DateInterval $accessTokenTTL
) { ) {
$requestParameters = (array) $request->getParsedBody(); if (array_key_exists('response_type', $request->getQueryParams())
&& $request->getQueryParams()['response_type'] === 'code'
if (array_key_exists('response_type', $requestParameters) && array_key_exists('client_id', $request->getQueryParams())
&& $requestParameters['response_type'] === 'code'
&& array_key_exists('client_id', $requestParameters)
) { ) {
return $this->respondToAuthorizationRequest($request); return $this->respondToAuthorizationRequest($request);
} elseif (array_key_exists('grant_type', $requestParameters) } elseif (parent::canRespondToRequest($request)) {
&& $requestParameters['grant_type'] === $this->getIdentifier()
) {
return $this->respondToAccessTokenRequest($request, $responseType, $accessTokenTTL); return $this->respondToAccessTokenRequest($request, $responseType, $accessTokenTTL);
} else { } else {
throw OAuthServerException::serverError('respondToRequest() should not have been called'); throw OAuthServerException::serverError('respondToRequest() should not have been called');
@ -336,13 +332,11 @@ class AuthCodeGrant extends AbstractGrant
*/ */
public function canRespondToRequest(ServerRequestInterface $request) public function canRespondToRequest(ServerRequestInterface $request)
{ {
$requestParameters = (array) $request->getParsedBody();
return ( return (
( (
array_key_exists('response_type', $requestParameters) array_key_exists('response_type', $request->getQueryParams())
&& $requestParameters['response_type'] === 'code' && $request->getQueryParams()['response_type'] === 'code'
&& array_key_exists('client_id', $requestParameters) && isset($request->getQueryParams()['client_id'])
) )
|| parent::canRespondToRequest($request) || parent::canRespondToRequest($request)
); );