Neos\Neos\Domain\Service\UserService::deactivateUser PHP Method

deactivateUser() public method

Deactivates the given user
public deactivateUser ( User $user ) : void
$user Neos\Neos\Domain\Model\User The user to deactivate
return void
    public function deactivateUser(User $user)
    {
        /** @var Account $account */
        foreach ($user->getAccounts() as $account) {
            $account->setExpirationDate($this->now);
            $this->accountRepository->update($account);
        }
        $this->emitUserDeactivated($user);
    }

Usage Example

 /**
  * Deactivate a user
  *
  * This command deactivates a user by flagging all of its accounts as expired.
  *
  * If an authentication provider is specified, this command will look for an account with the given username related
  * to the given provider. Still, this command will deactivate <b>all</b> accounts of a user, once such a user has been
  * found.
  *
  * @param string $username The username of the user to be deactivated.
  * @param string $authenticationProvider Name of the authentication provider to use for finding the user. Example: "Typo3BackendProvider"
  * @return void
  */
 public function deactivateCommand($username, $authenticationProvider = null)
 {
     $user = $this->getUserOrFail($username, $authenticationProvider);
     $this->userService->deactivateUser($user);
     $this->outputLine('Deactivated user "%s".', array($username));
 }