Skip to content
Snippets Groups Projects
Commit de96603c authored by Larry Garfield's avatar Larry Garfield
Browse files

Add an HTML listener for 403 errors.

parent 29824039
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -10,6 +10,7 @@
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
/**
* @file
......@@ -46,7 +47,9 @@ public function onView(GetResponseEvent $event) {
}
public function onAccessDeniedException(Event $event) {
if ($this->isHtmlRequestEvent($event) && $event->getException() instanceof AccessDeniedHttpException) {
$event->setResponse(new Response('Access Denied', 403));
}
}
static function getSubscribedEvents() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment