function AuthenticationSubscriber::onKernelRequestAuthenticate

Same name in other branches
  1. 9 core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php \Drupal\Core\EventSubscriber\AuthenticationSubscriber::onKernelRequestAuthenticate()
  2. 10 core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php \Drupal\Core\EventSubscriber\AuthenticationSubscriber::onKernelRequestAuthenticate()
  3. 11.x core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php \Drupal\Core\EventSubscriber\AuthenticationSubscriber::onKernelRequestAuthenticate()

Authenticates user on request.

Parameters

\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The request event.

See also

\Drupal\Core\Authentication\AuthenticationProviderInterface::authenticate()

File

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

Class

AuthenticationSubscriber
Authentication subscriber.

Namespace

Drupal\Core\EventSubscriber

Code

public function onKernelRequestAuthenticate(GetResponseEvent $event) {
    if ($event->isMasterRequest()) {
        $request = $event->getRequest();
        if ($this->authenticationProvider
            ->applies($request)) {
            $account = $this->authenticationProvider
                ->authenticate($request);
            if ($account) {
                $this->accountProxy
                    ->setAccount($account);
                return;
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.