Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AuthenticationSubscriber.php

function AuthenticationSubscriber::onExceptionAccessDenied

Detect disallowed authentication methods on access denied exceptions.

Parameters

\Symfony\Component\HttpKernel\Event\ExceptionEvent $event: The event.

File

core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php, line 130

Class

AuthenticationSubscriber
Authentication subscriber.

Namespace

Drupal\Core\EventSubscriber

Code

public function onExceptionAccessDenied(ExceptionEvent $event) {
    if (isset($this->filter) && $event->isMainRequest()) {
        $request = $event->getRequest();
        $exception = $event->getThrowable();
        if ($exception instanceof AccessDeniedHttpException && $this->authenticationProvider
            ->applies($request) && !$this->filter
            ->appliesToRoutedRequest($request, TRUE)) {
            $event->setThrowable(new AccessDeniedHttpException('The used authentication method is not allowed on this route.', $exception));
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal