From f01b5f8fd75c0857cea38797d311838bb3098c54 Mon Sep 17 00:00:00 2001 From: Artem Vasilev Date: Tue, 12 Mar 2024 11:57:11 +0300 Subject: [PATCH] View content --- .../site/src/Controller/LoginController.php | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/com_oauthserver/site/src/Controller/LoginController.php b/com_oauthserver/site/src/Controller/LoginController.php index 8e27ec3..bb886c9 100644 --- a/com_oauthserver/site/src/Controller/LoginController.php +++ b/com_oauthserver/site/src/Controller/LoginController.php @@ -11,6 +11,8 @@ namespace Webmasterskaya\Component\OauthServer\Site\Controller; use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Document\FactoryInterface; +use Joomla\CMS\Factory; use Joomla\CMS\MVC\Controller\BaseController; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\CMS\Router\Route; @@ -19,6 +21,7 @@ use Joomla\Input\Input; use Laminas\Diactoros\ServerRequestFactory; use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\CryptKey; +use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Grant\AuthCodeGrant; use League\OAuth2\Server\Grant\ClientCredentialsGrant; use League\OAuth2\Server\Grant\ImplicitGrant; @@ -176,11 +179,11 @@ class LoginController extends BaseController } /** - * @return void - * @throws \Exception + * @return LoginController + * @throws OAuthServerException * @since version */ - public function authorize(): void + public function authorize(): static { $app = $this->app; $user = $app->getIdentity(); @@ -225,20 +228,25 @@ class LoginController extends BaseController $authRequest->setAuthorizationApproved(true); $app->setResponse($server->completeAuthorizationRequest($authRequest, $serverResponse)); + + echo $this->app->getResponse()->getBody(); + + return $this; } /** - * @return void + * @return LoginController * @throws \Exception * @since version */ - public function token(): void + public function token(): static { $server = $this->authorizationServer; $serverRequest = ServerRequestFactory::fromGlobals(); $serverResponse = $this->app->getResponse(); $this->app->setResponse($server->respondToAccessTokenRequest($serverRequest, $serverResponse)); - $this->app->getInput()->set('format', 'json'); - //TODO: WTF!??!?! Какого хрена оно отдаёт простой HTML? + echo $this->app->getResponse()->getBody(); + + return $this; } }