Skip to content

Commit 361bf33

Browse files
bug #37504 [Security\Http] Skip remember-me logout on empty token (chalasr)
This PR was merged into the 5.1 branch. Discussion ---------- [Security\Http] Skip remember-me logout on empty token | Q | A | ------------- | --- | Branch? | 5.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #37501 | License | MIT | Doc PR | - Commits ------- 551f941 [Security\Http] Skip remember-me logout on empty token
2 parents 7da6d71 + 551f941 commit 361bf33

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/Symfony/Component/Security/Http/EventListener/RememberMeLogoutListener.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public function onLogout(LogoutEvent $event): void
4040
return;
4141
}
4242

43+
if (!$event->getToken()) {
44+
return;
45+
}
46+
4347
if (null === $event->getResponse()) {
4448
throw new LogicException(sprintf('No response was set for this logout action. Make sure the DefaultLogoutListener or another listener has set the response before "%s" is called.', __CLASS__));
4549
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Security\Http\Tests\EventListener;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\Request;
16+
use Symfony\Component\Security\Http\Event\LogoutEvent;
17+
use Symfony\Component\Security\Http\EventListener\RememberMeLogoutListener;
18+
use Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices;
19+
20+
class RememberMeLogoutListenerTest extends TestCase
21+
{
22+
public function testOnLogoutDoesNothingIfNoToken()
23+
{
24+
$rememberMeServices = $this->createMock(AbstractRememberMeServices::class);
25+
$rememberMeServices->expects($this->never())->method('logout');
26+
27+
$rememberMeLogoutListener = new RememberMeLogoutListener($rememberMeServices);
28+
$rememberMeLogoutListener->onLogout(new LogoutEvent(new Request(), null));
29+
}
30+
}

0 commit comments

Comments
 (0)
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