mirror of
https://github.com/webmasterskaya/joomla-oauth-server.git
synced 2024-11-23 18:24:50 +03:00
Switch to format json
This commit is contained in:
parent
f01b5f8fd7
commit
34289ae0e2
@ -22,57 +22,61 @@ use Joomla\Event\SubscriberInterface;
|
||||
|
||||
class Plugin extends CMSPlugin implements SubscriberInterface
|
||||
{
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return ['onAfterInitialise' => 'attachOauthRouter'];
|
||||
}
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return ['onAfterInitialise' => 'attachOauthRouter'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @since version
|
||||
*/
|
||||
public function attachOauthRouter(): void
|
||||
{
|
||||
/** @var \Joomla\CMS\Application\SiteApplication $app */
|
||||
$app = $this->getApplication();
|
||||
/**
|
||||
* @return void
|
||||
* @since version
|
||||
*/
|
||||
public function attachOauthRouter(): void
|
||||
{
|
||||
/** @var \Joomla\CMS\Application\SiteApplication $app */
|
||||
$app = $this->getApplication();
|
||||
|
||||
if (!$app->isClient('site'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!$app->isClient('site'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var \Joomla\CMS\Router\SiteRouter $siteRouter */
|
||||
$siteRouter = Factory::getContainer()->get(SiteRouter::class);
|
||||
$siteRouter->attachParseRule([$this, 'parseOauthRoute'], $siteRouter::PROCESS_BEFORE);
|
||||
}
|
||||
/** @var \Joomla\CMS\Router\SiteRouter $siteRouter */
|
||||
$siteRouter = Factory::getContainer()->get(SiteRouter::class);
|
||||
$siteRouter->attachParseRule([$this, 'parseOauthRoute'], $siteRouter::PROCESS_BEFORE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Joomla\CMS\Router\SiteRouter $router
|
||||
* @param \Joomla\CMS\Uri\Uri $uri
|
||||
*
|
||||
* @return void
|
||||
* @since version
|
||||
*/
|
||||
public function parseOauthRoute(SiteRouter &$router, Uri &$uri): void
|
||||
{
|
||||
$route = trim($uri->getPath(), '/');
|
||||
/**
|
||||
* @param \Joomla\CMS\Router\SiteRouter $router
|
||||
* @param \Joomla\CMS\Uri\Uri $uri
|
||||
*
|
||||
* @return void
|
||||
* @since version
|
||||
*/
|
||||
public function parseOauthRoute(SiteRouter &$router, Uri &$uri): void
|
||||
{
|
||||
$route = trim($uri->getPath(), '/');
|
||||
|
||||
if (empty($route))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (empty($route))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!str_starts_with($route, 'login/oauth'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!str_starts_with($route, 'login/oauth'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$segments = explode('/', $route);
|
||||
$segments = explode('/', $route);
|
||||
|
||||
$uri->setVar('option', 'com_oauthserver');
|
||||
$uri->setVar('task', 'login.' . $segments[2]);
|
||||
$uri->setVar('view', 'default');
|
||||
$uri->setVar('option', 'com_oauthserver');
|
||||
$uri->setVar('task', 'login.' . $segments[2]);
|
||||
if ($segments[2] !== 'authorize')
|
||||
{
|
||||
$uri->setVar('format', 'json');
|
||||
}
|
||||
$uri->setVar('view', 'default');
|
||||
|
||||
$uri->setPath('');
|
||||
}
|
||||
}
|
||||
$uri->setPath('');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user