You are here

public function AccountProxy::setAccount in Restrict Login or Role Access by IP Address 8.4

Sets the currently wrapped account.

Setting the current account is highly discouraged! Instead, make sure to inject the desired user object into the dependent code directly.

A preferable method of account impersonation is to use \Drupal\Core\Session\AccountSwitcherInterface::switchTo() and \Drupal\Core\Session\AccountSwitcherInterface::switchBack().

Parameters

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

Overrides AccountProxyInterface::setAccount

File

src/Session/AccountProxy.php, line 69
Contains \Drupal\restrict_by_ip\Session\AccountProxy.

Class

AccountProxy
When the current user is loaded, remove any roles that are restricted based on IP whitelists. Proxy all other method calls to the original current_user service.

Namespace

Drupal\restrict_by_ip\Session

Code

public function setAccount(AccountInterface $account) {
  $this->original
    ->setAccount($account);
}