Skip to content

Instantly share code, notes, and snippets.

@Tobur
Created October 25, 2013 08:51
Show Gist options
  • Save Tobur/7151622 to your computer and use it in GitHub Desktop.
Save Tobur/7151622 to your computer and use it in GitHub Desktop.
private function onFailure(GetResponseEvent $event, Request $request, AuthenticationException $failed)
{
if (null !== $this->logger) {
$this->logger->info(sprintf('Authentication request failed: %s', $failed->getMessage()));
}
$token = $this->securityContext->getToken();
if ($token instanceof UsernamePasswordToken && $this->providerKey === $token->getProviderKey()) {
$this->securityContext->setToken(null);
}
$response = $this->failureHandler->onAuthenticationFailure($request, $failed);
if (!$response instanceof Response) {
throw new \RuntimeException('Authentication Failure Handler did not return a Response.');
}
return $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment