W3cubDocs

/Drupal 8

public function AuthenticationSubscriber::onKernelRequestAuthenticate

public AuthenticationSubscriber::onKernelRequestAuthenticate(GetResponseEvent $event)

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 74

Class

AuthenticationSubscriber
Authentication subscriber.

Namespace

Drupal\Core\EventSubscriber

Code

public function onKernelRequestAuthenticate(GetResponseEvent $event) {
  if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
    $request = $event->getRequest();
    if ($this->authenticationProvider->applies($request)) {
      $account = $this->authenticationProvider->authenticate($request);
      if ($account) {
        $this->accountProxy->setAccount($account);
        return;
      }
    }
    // No account has been set explicitly, initialize the timezone here.
    date_default_timezone_set(drupal_get_user_timezone());
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!EventSubscriber!AuthenticationSubscriber.php/function/AuthenticationSubscriber::onKernelRequestAuthenticate/8.1.x