- md5
- 4bcc9dc1434ab7a4e54f3493cb1d95d0
- sha1
- 388783b1d04589bca4f3dbd73636c5ea7ac5be77
- sha256
- 5be3e216051b1b13bb6b84272ff5e30baba77d44e9f7630ce161c8df04bcda4f
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
<?php
/**
* @package Joomla.Plugin
* @subpackage System.logout
*
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\System\Logout\Extension;
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Application\CMSApplicationInterface;
use Joomla\CMS\Event\User\LogoutEvent;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Event\SubscriberInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Plugin class for logout redirect handling.
*
* @since 1.6
*/
final class Logout extends CMSPlugin implements SubscriberInterface
{
/**
* @param array $config An optional associative array of configuration settings.
* @param CMSApplicationInterface $app The object to observe -- event dispatcher.
*
* @since 1.6
*/
public function __construct(array $config, CMSApplicationInterface $app)
{
parent::__construct($config);
$this->setApplication($app);
// If we are on admin don't process.
if (!$this->getApplication()->isClient('site')) {
return;
}
$hash = ApplicationHelper::getHash('PlgSystemLogout');
if ($this->getApplication()->getInput()->cookie->getString($hash)) {
// Destroy the cookie.
$this->getApplication()->getInput()->cookie->set(
$hash,
'',
[
'expires' => 1,
'path' => $this->getApplication()->get('cookie_path', '/'),
'domain' => $this->getApplication()->get('cookie_domain', ''),
]
);
}
}
/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*
* @since 5.3.0
*/
public static function getSubscribedEvents(): array
{
return [
'onUserLogout' => 'onUserLogout',
];
}
/**
* Method to handle any logout logic and report back to the subject.
*
* @param LogoutEvent $event The event instance.
*
* @return void
*
* @since 1.6
*/
public function onUserLogout(LogoutEvent $event): void
{
if ($this->getApplication()->isClient('site')) {
// Create the cookie.
$this->getApplication()->getInput()->cookie->set(
ApplicationHelper::getHash('PlgSystemLogout'),
true,
[
'expires' => time() + 86400,
'path' => $this->getApplication()->get('cookie_path', '/'),
'domain' => $this->getApplication()->get('cookie_domain', ''),
'secure' => $this->getApplication()->isHttpsForced(),
'httponly' => true,
]
);
}
}
}
The same content is in 71 releases, Joomla 5.4.0-beta2 to 6.2.1-rc1. See them all, or every version of this file.