dispatch TokenRequestResolveEvent

This commit is contained in:
Artem Vasilev 2024-03-14 16:32:18 +03:00
parent f4ad545ba5
commit d1ff6dbd4f

View File

@ -26,6 +26,7 @@ use League\OAuth2\Server\Grant\ClientCredentialsGrant;
use League\OAuth2\Server\Grant\ImplicitGrant; use League\OAuth2\Server\Grant\ImplicitGrant;
use League\OAuth2\Server\Grant\RefreshTokenGrant; use League\OAuth2\Server\Grant\RefreshTokenGrant;
use League\OAuth2\Server\RequestEvent; 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\AccessTokenModel;
use Webmasterskaya\Component\OauthServer\Administrator\Model\AuthCodeModel; use Webmasterskaya\Component\OauthServer\Administrator\Model\AuthCodeModel;
use Webmasterskaya\Component\OauthServer\Administrator\Model\ClientModel; use Webmasterskaya\Component\OauthServer\Administrator\Model\ClientModel;
@ -270,8 +271,13 @@ class LoginController extends BaseController
{ {
$server = $this->authorizationServer; $server = $this->authorizationServer;
$serverRequest = ServerRequestFactory::fromGlobals(); $serverRequest = ServerRequestFactory::fromGlobals();
$serverResponse = $this->app->getResponse(); $response = $this->app->getResponse();
$this->app->setResponse($server->respondToAccessTokenRequest($serverRequest, $serverResponse)); $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(); echo $this->app->getResponse()->getBody();
return $this; return $this;