mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-22 13:09:44 +05:30
spec compliant 'error_description' but keep 'message' for BC
This commit is contained in:
parent
0227f14b7b
commit
b88198a9a4
@ -59,8 +59,8 @@ class OAuthServerException extends Exception
|
|||||||
$this->hint = $hint;
|
$this->hint = $hint;
|
||||||
$this->redirectUri = $redirectUri;
|
$this->redirectUri = $redirectUri;
|
||||||
$this->payload = [
|
$this->payload = [
|
||||||
'error' => $errorType,
|
'error' => $errorType,
|
||||||
'message' => $message,
|
'error_description' => $message,
|
||||||
];
|
];
|
||||||
if ($hint !== null) {
|
if ($hint !== null) {
|
||||||
$this->payload['hint'] = $hint;
|
$this->payload['hint'] = $hint;
|
||||||
@ -74,7 +74,15 @@ class OAuthServerException extends Exception
|
|||||||
*/
|
*/
|
||||||
public function getPayload()
|
public function getPayload()
|
||||||
{
|
{
|
||||||
return $this->payload;
|
$payload = $this->payload;
|
||||||
|
|
||||||
|
// The "message" property is deprecated and replaced by "error_description"
|
||||||
|
// TODO: remove "message" property
|
||||||
|
if (isset($payload['error_description']) && !isset($payload['message'])) {
|
||||||
|
$payload['message'] = $payload['error_description'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +104,7 @@ class AuthorizationServerMiddlewareTest extends TestCase
|
|||||||
$response = $exception->generateHttpResponse(new Response());
|
$response = $exception->generateHttpResponse(new Response());
|
||||||
|
|
||||||
$this->assertEquals(302, $response->getStatusCode());
|
$this->assertEquals(302, $response->getStatusCode());
|
||||||
$this->assertEquals('http://foo/bar?error=invalid_scope&message=The+requested+scope+is+invalid%2C+unknown%2C+or+malformed&hint=Check+the+%60test%60+scope',
|
$this->assertEquals('http://foo/bar?error=invalid_scope&error_description=The+requested+scope+is+invalid%2C+unknown%2C+or+malformed&hint=Check+the+%60test%60+scope&message=The+requested+scope+is+invalid%2C+unknown%2C+or+malformed',
|
||||||
$response->getHeader('location')[0]);
|
$response->getHeader('location')[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ class AuthorizationServerMiddlewareTest extends TestCase
|
|||||||
$response = $exception->generateHttpResponse(new Response(), true);
|
$response = $exception->generateHttpResponse(new Response(), true);
|
||||||
|
|
||||||
$this->assertEquals(302, $response->getStatusCode());
|
$this->assertEquals(302, $response->getStatusCode());
|
||||||
$this->assertEquals('http://foo/bar#error=invalid_scope&message=The+requested+scope+is+invalid%2C+unknown%2C+or+malformed&hint=Check+the+%60test%60+scope',
|
$this->assertEquals('http://foo/bar#error=invalid_scope&error_description=The+requested+scope+is+invalid%2C+unknown%2C+or+malformed&hint=Check+the+%60test%60+scope&message=The+requested+scope+is+invalid%2C+unknown%2C+or+malformed',
|
||||||
$response->getHeader('location')[0]);
|
$response->getHeader('location')[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user