[Security\Http] Skip remember-me logout on empty token
This commit is contained in:
parent
309b06201a
commit
551f9418a3
@ -40,6 +40,10 @@ class RememberMeLogoutListener implements EventSubscriberInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$event->getToken()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (null === $event->getResponse()) {
|
||||
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__));
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Security\Http\Tests\EventListener;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Security\Http\Event\LogoutEvent;
|
||||
use Symfony\Component\Security\Http\EventListener\RememberMeLogoutListener;
|
||||
use Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices;
|
||||
|
||||
class RememberMeLogoutListenerTest extends TestCase
|
||||
{
|
||||
public function testOnLogoutDoesNothingIfNoToken()
|
||||
{
|
||||
$rememberMeServices = $this->createMock(AbstractRememberMeServices::class);
|
||||
$rememberMeServices->expects($this->never())->method('logout');
|
||||
|
||||
$rememberMeLogoutListener = new RememberMeLogoutListener($rememberMeServices);
|
||||
$rememberMeLogoutListener->onLogout(new LogoutEvent(new Request(), null));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user