1. 8.5.x core/modules/user/src/Access/LoginStatusCheck.php LoginStatusCheck
  2. 8.0.x core/modules/user/src/Access/LoginStatusCheck.php LoginStatusCheck
  3. 8.1.x core/modules/user/src/Access/LoginStatusCheck.php LoginStatusCheck
  4. 8.2.x core/modules/user/src/Access/LoginStatusCheck.php LoginStatusCheck
  5. 8.3.x core/modules/user/src/Access/LoginStatusCheck.php LoginStatusCheck
  6. 8.4.x core/modules/user/src/Access/LoginStatusCheck.php LoginStatusCheck
  7. 8.6.x core/modules/user/src/Access/LoginStatusCheck.php LoginStatusCheck

Determines access to routes based on login status of current user.

Hierarchy

Expanded class hierarchy of LoginStatusCheck

1 string reference to 'LoginStatusCheck'
user.services.yml in core/modules/user/user.services.yml
core/modules/user/user.services.yml
1 service uses LoginStatusCheck

File

core/modules/user/src/Access/LoginStatusCheck.php, line 13

Namespace

Drupal\user\Access
View source
class LoginStatusCheck implements AccessInterface {

  /**
   * Checks access.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The currently logged in account.
   * @param \Symfony\Component\Routing\Route $route
   *   The route to check against.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function access(AccountInterface $account, Route $route) {
    $required_status = filter_var($route
      ->getRequirement('_user_is_logged_in'), FILTER_VALIDATE_BOOLEAN);
    $actual_status = $account
      ->isAuthenticated();
    return AccessResult::allowedIf($required_status === $actual_status)
      ->addCacheContexts([
      'user.roles:authenticated',
    ]);
  }

}

Members

Contains filters are case sensitive