From d1ff6dbd4fec702c17df2d2e55979f4ef61460bc Mon Sep 17 00:00:00 2001 From: Artem Vasilev Date: Thu, 14 Mar 2024 16:32:18 +0300 Subject: [PATCH] dispatch TokenRequestResolveEvent --- .../site/src/Controller/LoginController.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/com_oauthserver/site/src/Controller/LoginController.php b/com_oauthserver/site/src/Controller/LoginController.php index e37b66e..2d64354 100644 --- a/com_oauthserver/site/src/Controller/LoginController.php +++ b/com_oauthserver/site/src/Controller/LoginController.php @@ -26,6 +26,7 @@ use League\OAuth2\Server\Grant\ClientCredentialsGrant; use League\OAuth2\Server\Grant\ImplicitGrant; use League\OAuth2\Server\Grant\RefreshTokenGrant; use League\OAuth2\Server\RequestEvent; +use Webmasterskaya\Component\OauthServer\Administrator\Event\TokenRequestResolveEvent; use Webmasterskaya\Component\OauthServer\Administrator\Model\AccessTokenModel; use Webmasterskaya\Component\OauthServer\Administrator\Model\AuthCodeModel; use Webmasterskaya\Component\OauthServer\Administrator\Model\ClientModel; @@ -268,10 +269,15 @@ class LoginController extends BaseController */ public function token(): static { - $server = $this->authorizationServer; - $serverRequest = ServerRequestFactory::fromGlobals(); - $serverResponse = $this->app->getResponse(); - $this->app->setResponse($server->respondToAccessTokenRequest($serverRequest, $serverResponse)); + $server = $this->authorizationServer; + $serverRequest = ServerRequestFactory::fromGlobals(); + $response = $this->app->getResponse(); + $response = $server->respondToAccessTokenRequest($serverRequest, $response); + $event = new TokenRequestResolveEvent('onTokenRequestResolve', ['response' => $response]); + + $this->getDispatcher()->dispatch($event->getName(), $event); + $this->app->setResponse($event->getArgument('response')); + echo $this->app->getResponse()->getBody(); return $this;