summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Http/Firewall/ExceptionListener.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/Http/Firewall/ExceptionListener.php b/Http/Firewall/ExceptionListener.php
index 737d644..c757390 100644
--- a/Http/Firewall/ExceptionListener.php
+++ b/Http/Firewall/ExceptionListener.php
@@ -26,6 +26,7 @@ use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
+use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
@@ -113,16 +114,16 @@ class ExceptionListener
if (!$response instanceof Response) {
return;
}
- } else {
- if (null === $this->errorPage) {
- return;
- }
-
+ } elseif (null !== $this->errorPage) {
$subRequest = $this->httpUtils->createRequest($request, $this->errorPage);
$subRequest->attributes->set(SecurityContextInterface::ACCESS_DENIED_ERROR, $exception);
$response = $event->getKernel()->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true);
$response->setStatusCode(403);
+ } else {
+ $event->setException(new AccessDeniedHttpException($exception->getMessage(), $exception));
+
+ return;
}
} catch (\Exception $e) {
if (null !== $this->logger) {