You are here

public static function IpLoginController::canLoginAsAnotherUser in IP Login 4.x

Checks whether a user can log into another account.

Parameters

\Drupal\Core\Session\AccountInterface $user: The user account.

Return value

bool Returns TRUE if the given user can login into another account, FALSE otherwise.

1 call to IpLoginController::canLoginAsAnotherUser()
ip_login_user_logout in ./ip_login.module
Implements hook_user_logout().

File

src/IpLoginController.php, line 119

Class

IpLoginController

Namespace

Drupal\ip_login

Code

public static function canLoginAsAnotherUser(AccountInterface $user) {

  // People who can administer this module can.
  if ($user
    ->hasPermission('administer ip login')) {
    return TRUE;
  }

  // If the user doesn't have a matching IP, then we let them log in normally.
  if (!self::checkIpLoginExists(\Drupal::request())) {
    return TRUE;
  }

  // For all other users check the correct permission.
  return $user
    ->hasPermission('can log in as another user');
}