Skip to content

Commit

Permalink
Allow custom HTTP status code from AuthenticationRequiredHandler, #138
Browse files Browse the repository at this point in the history
  • Loading branch information
scheb committed Apr 16, 2022
1 parent 526796a commit 01fb822
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/bundle/Security/Http/Firewall/ExceptionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private function handleAccessDeniedException(ExceptionEvent $exceptionEvent): vo
$this->eventDispatcher->dispatch($event, TwoFactorAuthenticationEvents::REQUIRE);

$response = $this->authenticationRequiredHandler->onAuthenticationRequired($request, $token);
$exceptionEvent->allowCustomResponseCode();
$exceptionEvent->setResponse($response);
}

Expand Down
1 change: 1 addition & 0 deletions tests/Security/Http/Firewall/ExceptionListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ private function assertNotHasResponse(ExceptionEvent $event): void

private function assertHasResponse(ExceptionEvent $event, Response $response): void
{
$this->assertTrue($event->isAllowingCustomResponseCode());
$this->assertSame($response, $event->getResponse());
}

Expand Down

0 comments on commit 01fb822

Please sign in to comment.