Skip to content

Commit f936b41

Browse files
Xavier HAUSHERRfabpot
authored andcommitted
clearToken exception is thrown at wrong place.
1 parent be9f00a commit f936b41

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ final public function handle(GetResponseEvent $event)
6363
try {
6464
list($user, $credentials) = $this->getPreAuthenticatedData($request);
6565
} catch (BadCredentialsException $exception) {
66-
$this->clearToken();
66+
$this->clearToken($exception);
6767

6868
return;
6969
}
@@ -91,21 +91,23 @@ final public function handle(GetResponseEvent $event)
9191
$this->dispatcher->dispatch(SecurityEvents::INTERACTIVE_LOGIN, $loginEvent);
9292
}
9393
} catch (AuthenticationException $failed) {
94-
$this->clearToken();
94+
$this->clearToken($failed);
9595
}
9696
}
9797

9898
/**
9999
* Clears a PreAuthenticatedToken for this provider (if present)
100+
*
101+
* @param AuthenticationException $exception
100102
*/
101-
protected function clearToken()
103+
private function clearToken(AuthenticationException $exception)
102104
{
103105
$token = $this->securityContext->getToken();
104106
if ($token instanceof PreAuthenticatedToken && $this->providerKey === $token->getProviderKey()) {
105107
$this->securityContext->setToken(null);
106108

107109
if (null !== $this->logger) {
108-
$this->logger->info(sprintf("Cleared security context due to exception: %s", $failed->getMessage()));
110+
$this->logger->info(sprintf("Cleared security context due to exception: %s", $exception->getMessage()));
109111
}
110112
}
111113
}

0 commit comments

Comments
 (0)