public function AuthenticationSubscriber::onExceptionAccessDenied in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php \Drupal\Core\EventSubscriber\AuthenticationSubscriber::onExceptionAccessDenied()
- 10 core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php \Drupal\Core\EventSubscriber\AuthenticationSubscriber::onExceptionAccessDenied()
Detect disallowed authentication methods on access denied exceptions.
Parameters
\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event:
File
- core/
lib/ Drupal/ Core/ EventSubscriber/ AuthenticationSubscriber.php, line 129
Class
- AuthenticationSubscriber
- Authentication subscriber.
Namespace
Drupal\Core\EventSubscriberCode
public function onExceptionAccessDenied(GetResponseForExceptionEvent $event) {
if (isset($this->filter) && $event
->isMasterRequest()) {
$request = $event
->getRequest();
$exception = $event
->getException();
if ($exception instanceof AccessDeniedHttpException && $this->authenticationProvider
->applies($request) && !$this->filter
->appliesToRoutedRequest($request, TRUE)) {
$event
->setException(new AccessDeniedHttpException('The used authentication method is not allowed on this route.', $exception));
}
}
}