8000 Authentication(Success|Failure)Handler can now return null · symfony/symfony@ed9c348 · GitHub
[go: up one dir, main page]

Skip to content

Commit ed9c348

Browse files
author
Olivier Dolbeau
committed
Authentication(Success|Failure)Handler can now return null
1 parent 06da573 commit ed9c348

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/Symfony/Component/Security/Http/Authentication/AuthenticationFailureHandlerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ interface AuthenticationFailureHandlerInterface
3333
* @param Request $request
3434
* @param AuthenticationException $exception
3535
*
36-
* @return Response the response to return
36+
* @return Response|null the response to return
3737
*/
3838
function onAuthenticationFailure(Request $request, AuthenticationException $exception);
3939
}

src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ interface AuthenticationSuccessHandlerInterface
3333
* @param Request $request
3434
* @param TokenInterface $token
3535
*
36-
* @return Response the response to return
36+
* @return Response|null the response to return
3737
*/
3838
function onAuthenticationSuccess(Request $request, TokenInterface $token);
3939
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ private function onFailure(GetResponseEvent $event, Request $request, Authentica
192192
$this->securityContext->setToken(null);
193193

194194
if (null !== $this->failureHandler) {
195-
return $this->failureHandler->onAuthenticationFailure($request, $failed);
195+
if (null !== $response = $this->failureHandler->onAuthenticationFailure($request, $failed)) {
196+
return $response;
197+
}
196198
}
197199

198200
if (null === $this->options['failure_path']) {
@@ -236,9 +238,11 @@ private function onSuccess(GetResponseEvent $event, Request $request, TokenInter
236238
$this->dispatcher->dispatch(SecurityEvents::INTERACTIVE_LOGIN, $loginEvent);
237239
}
238240

241+
$response = null;
239242
if (null !== $this->successHandler) {
240243
$response = $this->successHandler->onAuthenticationSuccess($request, $token);
241-
} else {
244+
}
245+
if (null === $response) {
242246
$response = $this->httpUtils->createRedirectResponse($request, $this->determineTargetUrl($request));
243247
}
244248

0 commit comments

Comments
 (0)
0