|
@@ -26,6 +26,7 @@ use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|
use Symfony\Component\HttpKernel\KernelEvents;
|
|
use Symfony\Component\HttpKernel\KernelEvents;
|
|
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
|
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
|
|
|
+use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -113,16 +114,16 @@ class ExceptionListener
|
|
if (!$response instanceof Response) {
|
|
if (!$response instanceof Response) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- if (null === $this->errorPage) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ } elseif (null !== $this->errorPage) {
|
|
$subRequest = $this->httpUtils->createRequest($request, $this->errorPage);
|
|
$subRequest = $this->httpUtils->createRequest($request, $this->errorPage);
|
|
$subRequest->attributes->set(SecurityContextInterface::ACCESS_DENIED_ERROR, $exception);
|
|
$subRequest->attributes->set(SecurityContextInterface::ACCESS_DENIED_ERROR, $exception);
|
|
|
|
|
|
$response = $event->getKernel()->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true);
|
|
$response = $event->getKernel()->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true);
|
|
$response->setStatusCode(403);
|
|
$response->setStatusCode(403);
|
|
|
|
+ } else {
|
|
|
|
+ $event->setException(new AccessDeniedHttpException($exception->getMessage(), $exception));
|
|
|
|
+
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
if (null !== $this->logger) {
|
|
if (null !== $this->logger) {
|