fixed bug

This commit is contained in:
Fabien Potencier 2014-09-23 16:12:58 +02:00
parent e85cb7fe2a
commit faa8e98063

View File

@ -21,7 +21,6 @@ use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface; use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
/** /**
* SimplePreAuthenticationListener implements simple proxying to an authenticator. * SimplePreAuthenticationListener implements simple proxying to an authenticator.
@ -76,13 +75,15 @@ class SimplePreAuthenticationListener implements ListenerInterface
} }
try { try {
$this->securityContext->setToken(null);
$token = $this->simpleAuthenticator->createToken($request, $this->providerKey); $token = $this->simpleAuthenticator->createToken($request, $this->providerKey);
if ($token instanceof TokenInterface) { // allow null to be returned to skip authentication
$token = $this->authenticationManager->authenticate($token); if (null === $token) {
$this->securityContext->setToken($token); return;
} }
$token = $this->authenticationManager->authenticate($token);
$this->securityContext->setToken($token);
} catch (AuthenticationException $e) { } catch (AuthenticationException $e) {
$this->securityContext->setToken(null); $this->securityContext->setToken(null);