Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 348bccb

Browse files
committed
Clear session cookie if user was deleted, is disabled or locked to prevent infinite redirect loops to the login path (fixes #1798).
1 parent 9dbe782 commit 348bccb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Security\Core\SecurityContextInterface;
1717
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
1818
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
19+
use Symfony\Component\Security\Core\Exception\AccountStatusException;
1920
use Symfony\Component\Security\Core\Exception\AuthenticationException;
2021
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
2122
use Symfony\Component\Security\Core\Exception\InsufficientAuthenticationException;
@@ -158,7 +159,15 @@ private function startAuthentication(Request $request, AuthenticationException $
158159

159160
$this->setTargetPath($request);
160161

161-
return $this->authenticationEntryPoint->start($request, $authException);
162+
$response = $this->authenticationEntryPoint->start($request, $authException);
163+
164+
if ($authException instanceof AccountStatusException && $response instanceof Response) {
165+
// clear the session cookie to prevent infinite redirect loops
166+
$cookieParams = session_get_cookie_params();
167+
$response->headers->clearCookie(session_name(), $cookieParams['path'], $cookieParams['domain']);
168+
}
169+
170+
return $response;
162171
}
163172

164173
protected function setTargetPath(Request $request)

0 commit comments

Comments
 (0)