diff options
author | adenkejawen <muhamad@sanisphere.com> | 2014-07-18 10:15:01 +0700 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2014-09-23 16:11:05 +0200 |
commit | ffd73a83c73bb07016d2ef4e84bbd76f92121573 (patch) | |
tree | 0ca7a7719586a2fbfb314d4afa0fc4e781e986a0 | |
parent | 78ebbab243651e31b940cb1330b06361dbd3c37b (diff) | |
download | symfony-security-ffd73a83c73bb07016d2ef4e84bbd76f92121573.zip symfony-security-ffd73a83c73bb07016d2ef4e84bbd76f92121573.tar.gz symfony-security-ffd73a83c73bb07016d2ef4e84bbd76f92121573.tar.bz2 |
added the possibility to return null from SimplePreAuthenticationListener
-rw-r--r-- | Http/Firewall/SimplePreAuthenticationListener.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Http/Firewall/SimplePreAuthenticationListener.php b/Http/Firewall/SimplePreAuthenticationListener.php index 258ca96..47996b2 100644 --- a/Http/Firewall/SimplePreAuthenticationListener.php +++ b/Http/Firewall/SimplePreAuthenticationListener.php @@ -21,6 +21,7 @@ use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface; use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; /** * SimplePreAuthenticationListener implements simple proxying to an authenticator. @@ -75,9 +76,13 @@ class SimplePreAuthenticationListener implements ListenerInterface } try { + $this->securityContext->setToken(null); $token = $this->simpleAuthenticator->createToken($request, $this->providerKey); - $token = $this->authenticationManager->authenticate($token); - $this->securityContext->setToken($token); + + if ($token instanceof TokenInterface) { + $token = $this->authenticationManager->authenticate($token); + $this->securityContext->setToken($token); + } } catch (AuthenticationException $e) { $this->securityContext->setToken(null); |