public function Cookie::addCheckToUrl in Drupal 9
Adds a query parameter to check successful log in redirect URL.
Parameters
\Symfony\Component\HttpKernel\Event\ResponseEvent $event: The Event to process.
File
- core/
modules/ user/ src/ Authentication/ Provider/ Cookie.php, line 127
Class
- Cookie
- Cookie based authentication provider.
Namespace
Drupal\user\Authentication\ProviderCode
public function addCheckToUrl(ResponseEvent $event) {
$response = $event
->getResponse();
if ($response instanceof RedirectResponse && $event
->getRequest()
->hasSession()) {
if ($event
->getRequest()
->getSession()
->has('check_logged_in')) {
$event
->getRequest()
->getSession()
->remove('check_logged_in');
$url = $response
->getTargetUrl();
$options = UrlHelper::parse($url);
$options['query']['check_logged_in'] = '1';
$url = $options['path'] . '?' . UrlHelper::buildQuery($options['query']);
if (!empty($options['#fragment'])) {
$url .= '#' . $options['#fragment'];
}
$response
->setTargetUrl($url);
}
}
}