Skip to content

Commit f870761

Browse files
Throw Exception when logout handler is called
1 parent 38bcf19 commit f870761

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Security/Http/Logout/ContextInvalidationLogoutHandler.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
18+
use Symfony\Component\Security\Http\Event\LogoutEvent;
1819
use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface;
1920

2021
/**
@@ -38,6 +39,13 @@ public function __construct(UserContextInvalidator $invalidator)
3839
public function logout(Request $request, Response $response, TokenInterface $token)
3940
{
4041
@trigger_error('Using the ContextInvalidationLogoutHandler is deprecated', E_USER_DEPRECATED);
42+
43+
if (class_exists(LogoutEvent::class)) {
44+
// This function should not longer be called in Symfony 5.1
45+
// See also: https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/pull/545#discussion_r465089219
46+
throw new \LogicException(__CLASS__ . '::' . __METHOD__ . ' is deprecated and should since Symfony 5.1 not longer be called.');
47+
}
48+
4149
$this->invalidator->invalidateContext($request->getSession()->getId());
4250
}
4351
}

tests/Functional/Security/Http/Logout/ContextInvalidationLogoutHandlerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function testLogout()
2626
{
2727
if (class_exists(LogoutEvent::class)) {
2828
// @see https://github.com/symfony/symfony/pull/36243/files#r465083756
29+
// @see https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/pull/545/files#diff-05cbcfd492fd361b33ee70130dc687b2
2930
$this->markTestSkipped('This test does not work with Symfony 5.1.');
3031
}
3132

0 commit comments

Comments
 (0)