You are here

protected function DomainTestBase::drupalUserIsLoggedIn in Domain Access 8

Returns whether a given user account is logged in.

Parameters

\Drupal\Core\Session\AccountInterface $account: The user account object to check.

Return value

bool TRUE if a given user account is logged in, or FALSE.

Overrides UiHelperTrait::drupalUserIsLoggedIn

1 call to DomainTestBase::drupalUserIsLoggedIn()
DomainTestBase::domainLogin in domain/tests/src/Functional/DomainTestBase.php
Login a user on a specific domain.

File

domain/tests/src/Functional/DomainTestBase.php, line 226

Class

DomainTestBase
Class DomainTestBase.

Namespace

Drupal\Tests\domain\Functional

Code

protected function drupalUserIsLoggedIn(AccountInterface $account) {

  // @TODO: This is a temporary hack for the test login fails when setting $cookie_domain.
  if (!isset($account->session_id)) {
    return (bool) $account
      ->id();
  }

  // The session ID is hashed before being stored in the database.
  // @see \Drupal\Core\Session\SessionHandler::read()
  return (bool) $this->database
    ->query("SELECT sid FROM {users_field_data} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid", [
    ':sid' => Crypt::hashBase64($account->session_id),
  ])
    ->fetchField();
}