diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/DummyToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/DummyToken.php new file mode 100644 index 0000000000000..9193d6fcc49a4 --- /dev/null +++ b/src/Symfony/Component/Security/Core/Authentication/Token/DummyToken.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Security\Core\Authentication\Token; + +/** + * DummyToken allows fixing #7104 without introducing any BC break. + * + * @author Mathieu Lechat + * + * @internal + */ +class DummyToken extends AbstractToken +{ + public function __construct() + { + parent::__construct(array()); + + $this->setUser('dummy'); + } + + /** + * {@inheritdoc} + */ + public function getCredentials() + { + return null; + } +} diff --git a/src/Symfony/Component/Security/Http/Firewall/LogoutListener.php b/src/Symfony/Component/Security/Http/Firewall/LogoutListener.php index 5b5ccbff1009d..ed4b7f5a85cec 100644 --- a/src/Symfony/Component/Security/Http/Firewall/LogoutListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/LogoutListener.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\Security\Core\Authentication\Token\DummyToken; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Exception\InvalidArgumentException; use Symfony\Component\Security\Core\Exception\LogoutException; @@ -109,10 +110,12 @@ public function handle(GetResponseEvent $event) } // handle multiple logout attempts gracefully - if ($token = $this->tokenStorage->getToken()) { - foreach ($this->handlers as $handler) { - $handler->logout($request, $response, $token); - } + $token = $this->tokenStorage->getToken(); + if (null === $token) { + $token = new DummyToken(); + } + foreach ($this->handlers as $handler) { + $handler->logout($request, $response, $token); } $this->tokenStorage->setToken(null); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy