mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-27 01:02:12 +05:30
Renamed server respondToRequest
to respondToAccessTokenRequest
This commit is contained in:
parent
6ee71754c4
commit
4689802c30
@ -50,7 +50,7 @@ $app->post('/access_token', function (ServerRequestInterface $request, ResponseI
|
||||
$server = $app->getContainer()->get(Server::class);
|
||||
|
||||
try {
|
||||
return $server->respondToRequest($request, $response);
|
||||
return $server->respondToAccessTokenRequest($request, $response);
|
||||
} catch (OAuthServerException $exception) {
|
||||
return $exception->generateHttpResponse($response);
|
||||
} catch (\Exception $exception) {
|
||||
|
@ -54,7 +54,7 @@ $app->post('/access_token', function (ServerRequestInterface $request, ResponseI
|
||||
$server = $app->getContainer()->get(Server::class);
|
||||
|
||||
try {
|
||||
return $server->respondToRequest($request, $response);
|
||||
return $server->respondToAccessTokenRequest($request, $response);
|
||||
} catch (OAuthServerException $exception) {
|
||||
return $exception->generateHttpResponse($response);
|
||||
} catch (\Exception $exception) {
|
||||
|
@ -52,7 +52,7 @@ $app->post('/access_token', function (ServerRequestInterface $request, ResponseI
|
||||
$server = $app->getContainer()->get(Server::class);
|
||||
|
||||
try {
|
||||
return $server->respondToRequest($request, $response);
|
||||
return $server->respondToAccessTokenRequest($request, $response);
|
||||
} catch (OAuthServerException $exception) {
|
||||
return $exception->generateHttpResponse($response);
|
||||
} catch (\Exception $exception) {
|
||||
|
@ -134,7 +134,7 @@ class Server implements EmitterAwareInterface
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function respondToRequest(ServerRequestInterface $request, ResponseInterface $response)
|
||||
public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response)
|
||||
{
|
||||
$tokenResponse = null;
|
||||
while ($tokenResponse === null && $grantType = array_shift($this->enabledGrantTypes)) {
|
||||
|
@ -38,7 +38,7 @@ class ServerTest extends \PHPUnit_Framework_TestCase
|
||||
$server->enableGrantType(new ClientCredentialsGrant(), new \DateInterval('PT1M'));
|
||||
|
||||
try {
|
||||
$server->respondToRequest(ServerRequestFactory::fromGlobals(), new Response);
|
||||
$server->respondToAccessTokenRequest(ServerRequestFactory::fromGlobals(), new Response);
|
||||
} catch (OAuthServerException $e) {
|
||||
$this->assertEquals('unsupported_grant_type', $e->getErrorType());
|
||||
$this->assertEquals(400, $e->getHttpStatusCode());
|
||||
@ -70,7 +70,7 @@ class ServerTest extends \PHPUnit_Framework_TestCase
|
||||
$_POST['grant_type'] = 'client_credentials';
|
||||
$_POST['client_id'] = 'foo';
|
||||
$_POST['client_secret'] = 'bar';
|
||||
$response = $server->respondToRequest(ServerRequestFactory::fromGlobals(), new Response);
|
||||
$response = $server->respondToAccessTokenRequest(ServerRequestFactory::fromGlobals(), new Response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ class ServerTest extends \PHPUnit_Framework_TestCase
|
||||
$_POST['action'] = 'approve';
|
||||
$_POST['username'] = 'user';
|
||||
$_POST['password'] = 'pass';
|
||||
$response = $server->respondToRequest(ServerRequestFactory::fromGlobals(), new Response);
|
||||
$response = $server->respondToAccessTokenRequest(ServerRequestFactory::fromGlobals(), new Response);
|
||||
$this->assertTrue($response instanceof ResponseInterface);
|
||||
$this->assertEquals(302, $response->getStatusCode());
|
||||
$this->assertTrue(strstr($response->getHeaderLine('location'), 'code=') !== false);
|
||||
|
Loading…
Reference in New Issue
Block a user