Skip to content

Commit

Permalink
added the possibility to return null from SimplePreAuthenticationList…
Browse files Browse the repository at this point in the history
…ener
  • Loading branch information
adenkejawen authored and fabpot committed Sep 23, 2014
1 parent 924d06a commit e85cb7f
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -21,6 +21,7 @@
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.
Expand Down Expand Up @@ -75,9 +76,13 @@ public function handle(GetResponseEvent $event)
}

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);

Expand Down

0 comments on commit e85cb7f

Please sign in to comment.