From ed9c34822b71af7c95a4824ff0853b91d87f1bb6 Mon Sep 17 00:00:00 2001 From: Olivier Dolbeau Date: Tue, 24 Jan 2012 17:36:01 +0100 Subject: [PATCH] Authentication(Success|Failure)Handler can now return null --- .../AuthenticationFailureHandlerInterface.php | 2 +- .../AuthenticationSuccessHandlerInterface.php | 2 +- .../Http/Firewall/AbstractAuthenticationListener.php | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Security/Http/Authentication/AuthenticationFailureHandlerInterface.php b/src/Symfony/Component/Security/Http/Authentication/AuthenticationFailureHandlerInterface.php index d5d0067282..7a5cc23ce3 100644 --- a/src/Symfony/Component/Security/Http/Authentication/AuthenticationFailureHandlerInterface.php +++ b/src/Symfony/Component/Security/Http/Authentication/AuthenticationFailureHandlerInterface.php @@ -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); } diff --git a/src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php b/src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php index 3d7c5610ae..1a46ad4b6c 100644 --- a/src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php +++ b/src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php @@ -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); } diff --git a/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php index 99f92b8e3b..4c6689e198 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php @@ -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)); }