diff options
author | Christophe Coevoet <stof@notk.org> | 2011-07-11 13:12:24 +0200 |
---|---|---|
committer | Christophe Coevoet <stof@notk.org> | 2011-07-11 13:12:24 +0200 |
commit | ad6ee1fb40c193ddb4e79432c03b771591760122 (patch) | |
tree | 15e87c97286733992b678bff899e48c2edde7667 /Http | |
parent | 24f60c28bd53c67ba1febc4192b8ea10fba03c6f (diff) | |
download | symfony-security-ad6ee1fb40c193ddb4e79432c03b771591760122.zip symfony-security-ad6ee1fb40c193ddb4e79432c03b771591760122.tar.gz symfony-security-ad6ee1fb40c193ddb4e79432c03b771591760122.tar.bz2 |
Added a AccessDeniedHttpException to wrap the AccessDeniedException.
See #1631
Diffstat (limited to 'Http')
-rw-r--r-- | Http/Firewall/ExceptionListener.php | 11 |
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) { |