Authentication(Success|Failure)Handler can now return null

This commit is contained in:
Olivier Dolbeau 2012-01-24 17:36:01 +01:00
parent 06da573d04
commit ed9c34822b
3 changed files with 8 additions and 4 deletions

View File

@ -33,7 +33,7 @@ interface AuthenticationFailureHandlerInterface
* @param Request $request
* @param AuthenticationException $exception
*
* @return Response the response to return
* @return Response|null the response to return
*/
function onAuthenticationFailure(Request $request, AuthenticationException $exception);
}

View File

@ -33,7 +33,7 @@ interface AuthenticationSuccessHandlerInterface
* @param Request $request
* @param TokenInterface $token
*
* @return Response the response to return
* @return Response|null the response to return
*/
function onAuthenticationSuccess(Request $request, TokenInterface $token);
}

View File

@ -192,7 +192,9 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
$this->securityContext->setToken(null);
if (null !== $this->failureHandler) {
return $this->failureHandler->onAuthenticationFailure($request, $failed);
if (null !== $response = $this->failureHandler->onAuthenticationFailure($request, $failed)) {
return $response;
}
}
if (null === $this->options['failure_path']) {
@ -236,9 +238,11 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
$this->dispatcher->dispatch(SecurityEvents::INTERACTIVE_LOGIN, $loginEvent);
}
$response = null;
if (null !== $this->successHandler) {
$response = $this->successHandler->onAuthenticationSuccess($request, $token);
} else {
}
if (null === $response) {
$response = $this->httpUtils->createRedirectResponse($request, $this->determineTargetUrl($request));
}