Piwik\Plugins\UsersManager\API::getUser PHP Method

getUser() public method

Returns the user information (login, password hash, alias, email, date_registered, etc.)
public getUser ( string $userLogin ) : array
$userLogin string the user login
return array the user information
    public function getUser($userLogin)
    {
        Piwik::checkUserHasSuperUserAccessOrIsTheUser($userLogin);
        $this->checkUserExists($userLogin);
        $user = $this->model->getUser($userLogin);
        $user = $this->userFilter->filterUser($user);
        $user = $this->enrichUser($user);
        return $user;
    }

Usage Example

コード例 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $login = $input->getArgument('login');
     $user = $this->usersManagerApi->getUser($login);
     if (!UserMapper::isUserLdapUser($user)) {
         throw new Exception("User '{$login}' is not an LDAP user. To regenerate this user's token_auth, change the user's password.");
     }
     if (!$this->userMapper->isRandomTokenAuthGenerationEnabled()) {
         throw new Exception("Random token_auth generation is disabled in [LoginLdap] config. This means any changes made by this " . "command will be overwritten when the user logs in. Aborting.");
     }
     $newPassword = $this->userMapper->generateRandomPassword();
     $this->usersManagerApi->updateUser($login, $newPassword, $email = false, $alias = false, $isPasswordHash = true);
     $user = $this->usersManagerApi->getUser($login);
     $this->writeSuccessMessage($output, array("token_auth for '{$login}' regenerated successfully, new token_auth = '{$user['token_auth']}'"));
 }
All Usage Examples Of Piwik\Plugins\UsersManager\API::getUser