From f936b41a90bec3855a53b79dc81ad0c1fbabbca4 Mon Sep 17 00:00:00 2001 From: Xavier HAUSHERR Date: Thu, 22 Aug 2013 15:12:32 +0200 Subject: [PATCH] clearToken exception is thrown at wrong place. --- .../Http/Firewall/AbstractPreAuthenticatedListener.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php b/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php index e248c6de5e..fdc2e8c75c 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php @@ -63,7 +63,7 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface try { list($user, $credentials) = $this->getPreAuthenticatedData($request); } catch (BadCredentialsException $exception) { - $this->clearToken(); + $this->clearToken($exception); return; } @@ -91,21 +91,23 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface $this->dispatcher->dispatch(SecurityEvents::INTERACTIVE_LOGIN, $loginEvent); } } catch (AuthenticationException $failed) { - $this->clearToken(); + $this->clearToken($failed); } } /** * Clears a PreAuthenticatedToken for this provider (if present) + * + * @param AuthenticationException $exception */ - protected function clearToken() + private function clearToken(AuthenticationException $exception) { $token = $this->securityContext->getToken(); if ($token instanceof PreAuthenticatedToken && $this->providerKey === $token->getProviderKey()) { $this->securityContext->setToken(null); if (null !== $this->logger) { - $this->logger->info(sprintf("Cleared security context due to exception: %s", $failed->getMessage())); + $this->logger->info(sprintf("Cleared security context due to exception: %s", $exception->getMessage())); } } }