mirror of
https://github.com/webmasterskaya/joomla-oauth-server.git
synced 2024-11-23 22:34:50 +03:00
View content
This commit is contained in:
parent
018dae734f
commit
f01b5f8fd7
@ -11,6 +11,8 @@ namespace Webmasterskaya\Component\OauthServer\Site\Controller;
|
|||||||
|
|
||||||
use Joomla\CMS\Application\CMSApplication;
|
use Joomla\CMS\Application\CMSApplication;
|
||||||
use Joomla\CMS\Component\ComponentHelper;
|
use Joomla\CMS\Component\ComponentHelper;
|
||||||
|
use Joomla\CMS\Document\FactoryInterface;
|
||||||
|
use Joomla\CMS\Factory;
|
||||||
use Joomla\CMS\MVC\Controller\BaseController;
|
use Joomla\CMS\MVC\Controller\BaseController;
|
||||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||||
use Joomla\CMS\Router\Route;
|
use Joomla\CMS\Router\Route;
|
||||||
@ -19,6 +21,7 @@ use Joomla\Input\Input;
|
|||||||
use Laminas\Diactoros\ServerRequestFactory;
|
use Laminas\Diactoros\ServerRequestFactory;
|
||||||
use League\OAuth2\Server\AuthorizationServer;
|
use League\OAuth2\Server\AuthorizationServer;
|
||||||
use League\OAuth2\Server\CryptKey;
|
use League\OAuth2\Server\CryptKey;
|
||||||
|
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||||
use League\OAuth2\Server\Grant\AuthCodeGrant;
|
use League\OAuth2\Server\Grant\AuthCodeGrant;
|
||||||
use League\OAuth2\Server\Grant\ClientCredentialsGrant;
|
use League\OAuth2\Server\Grant\ClientCredentialsGrant;
|
||||||
use League\OAuth2\Server\Grant\ImplicitGrant;
|
use League\OAuth2\Server\Grant\ImplicitGrant;
|
||||||
@ -176,11 +179,11 @@ class LoginController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return LoginController
|
||||||
* @throws \Exception
|
* @throws OAuthServerException
|
||||||
* @since version
|
* @since version
|
||||||
*/
|
*/
|
||||||
public function authorize(): void
|
public function authorize(): static
|
||||||
{
|
{
|
||||||
$app = $this->app;
|
$app = $this->app;
|
||||||
$user = $app->getIdentity();
|
$user = $app->getIdentity();
|
||||||
@ -225,20 +228,25 @@ class LoginController extends BaseController
|
|||||||
$authRequest->setAuthorizationApproved(true);
|
$authRequest->setAuthorizationApproved(true);
|
||||||
|
|
||||||
$app->setResponse($server->completeAuthorizationRequest($authRequest, $serverResponse));
|
$app->setResponse($server->completeAuthorizationRequest($authRequest, $serverResponse));
|
||||||
|
|
||||||
|
echo $this->app->getResponse()->getBody();
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return LoginController
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @since version
|
* @since version
|
||||||
*/
|
*/
|
||||||
public function token(): void
|
public function token(): static
|
||||||
{
|
{
|
||||||
$server = $this->authorizationServer;
|
$server = $this->authorizationServer;
|
||||||
$serverRequest = ServerRequestFactory::fromGlobals();
|
$serverRequest = ServerRequestFactory::fromGlobals();
|
||||||
$serverResponse = $this->app->getResponse();
|
$serverResponse = $this->app->getResponse();
|
||||||
$this->app->setResponse($server->respondToAccessTokenRequest($serverRequest, $serverResponse));
|
$this->app->setResponse($server->respondToAccessTokenRequest($serverRequest, $serverResponse));
|
||||||
$this->app->getInput()->set('format', 'json');
|
echo $this->app->getResponse()->getBody();
|
||||||
//TODO: WTF!??!?! Какого хрена оно отдаёт простой HTML?
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user