Search User with given username, optionally at given location.

@param string $username name of User to search for
@param string $parentGroupLocationId where to search, in User Group tree

@return User found
762342
public function searchUserByLogin($username, $parentGroupId = null)
    {
        try {
            $user = $this->userService->loadUserByLogin($username);
        } catch (ApiExceptions\NotFoundException $e) {
            return null;
        }

        if ($user && $parentGroupId) {
            $userGroups = $this->userService->loadUserGroupsOfUser($user);

            foreach ($userGroups as $userGroup) {
                if ($userGroup->getVersionInfo()->getContentInfo()->id == $parentGroupId) {
                    return $user;
                }
            }
            // user not found in $parentGroupId
            return null;
        }

        return $user;
    }
607891
public function findRoleNamesByUserId($userId)
    {
        $query = $this->getSqlObject()
            ->select()
            ->join('user_roles', 'user_roles.id = pvt_roles_users.role_id', ['name'])
            ->where(['user_id' => $userId]);

        $results = $this->execute($query)->toArray();

        return Arr::pluck($results, 'name');
    }
570849
public static function getUsersByGroup($groupId, $recursive = false)
	{
		$test = $recursive ? '>=' : '=';

		// First find the users contained in the group
		$db = App::get('db');
		$query = $db->getQuery()
			->select('DISTINCT(user_id)')
			->from('#__usergroups', 'ug1')
			->joinRaw('#__usergroups AS ug2', 'ug2.lft' . $test . 'ug1.lft AND ug1.rgt' . $test . 'ug2.rgt', 'inner')
			->join('#__user_usergroup_map AS m', 'm.group_id', 'ug2.id', 'inner')
			->whereEquals('ug1.id', $groupId);

		$db->setQuery($query->toString());

		$result = $db->loadColumn();

		// Clean up any NULL values, just in case
		Arr::toInteger($result);

		return $result;
	}
61191
protected function getLocalUser(string $provider, string $providerUserId)
    {
        return app('cortex.auth.admin')->whereHas('socialites', function (Builder $builder) use ($provider, $providerUserId) {
            $builder->where('provider', $provider)->where('provider_uid', $providerUserId);
        })->first();
    }
478597
public static function findByUser( $parentId, $parentType, $userId, $type = ModelComment::TYPE_COMMENT ) {

		return static::find()->where( 'parentId=:pid AND parentType=:ptype AND createdBy=:uid AND type=:type', [ ':pid' => $parentId, ':ptype' => $parentType, ':uid' => $userId, ':type' => $type ] )->one();
	}
419244
public static function findByParentModelId( $parentId, $parentType, $modelId ) {

		return self::queryByParentModelId( $parentId, $parentType, $modelId )->all();
	}
587623
public function loadUrlWildcardData($parentId)
    {
        try {
            return $this->innerGateway->loadUrlWildcardData($parentId);
        } catch (DBALException $e) {
            throw new \RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new \RuntimeException('Database error', 0, $e);
        }
    }
874340
public static function findByType( $parentId, $parentType, $type, $config = [] ) {

		return self::queryByType( $parentId, $parentType, $type, $config )->all();
	}
130578
public function findByStatusIdAndUser($locale, $statusId, UserInterface $user, $limit = null)
    {
        return $this->findByStatusIdsAndUser($locale, [$statusId], $user, $limit);
    }
1307438
@Transactional
    @Override
    public PrincipalUser findUserByUsername(String userName) {
    	requireNotDisposed();
        requireArgument(userName != null && !userName.trim().isEmpty(), "User name cannot be null or empty.");

        PrincipalUser result = PrincipalUser.findByUserName(emf.get(), userName);

        _logger.debug("Retrieving user having username {} from db.", userName);
        return result;
    }
659379
public function get($parentUuid, $uuid)
    {
        // Check parent exists
        $parentModel = static::$parentModel;
        $parentResource = $parentModel::findOrFail($parentUuid);

        // Authorize ability to view children model for parent
        $this->authorizeUserAction($this->parentAbilitiesRequired['view'], $parentResource);

        // Get resource
        $model = new static::$model;
        $resource = $model::with($model::$localWith)->where($model->getKeyName(), '=', $uuid)->firstOrFail();

        // Check resource belongs to parent
        if ($resource->getAttribute(($parentResource->getKeyName())) != $parentResource->getKey()) {
            throw new AccessDeniedHttpException('Resource \'' . class_basename(static::$model) . '\' with given UUID ' . $uuid . ' does not belong to ' .
                'resource \'' . class_basename(static::$parentModel) . '\' with given UUID ' . $parentUuid . '; ');
        }

        if (! $resource) {
            throw new NotFoundHttpException('Resource \'' . class_basename(static::$model) . '\' with given UUID ' . $uuid . ' not found');
        }

        // Authorize ability to create this model
        $this->authorizeUserAction('view', $resource);

        return $this->response->item($resource, $this->getTransformer());
    }
651035
public static function findByParentId( $parentId, $config = [] ) {

		$ignoreSite	= isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;

		if( static::isMultiSite() && !$ignoreSite ) {

			$siteId	= isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;

			return static::find()->where( 'parentId=:pid AND siteId=:siteId', [ ':pid' => $parentId, ':siteId' => $siteId ] )->all();
		}
		else {

			return static::find()->where( 'parentId=:pid', [ ':pid' => $parentId ] )->all();
		}
	}
1027732
private function findUserByUsernameOrThrowException($username)
    {
        $user = $this->userManager->findUserByUsername($username);

        if (!$user) {
            throw new InvalidArgumentException(sprintf('User identified by "%s" username does not exist.', $username));
        }

        return $user;
    }
30031
public function search($name,$parent_id = null){
		if ($parent_id)
			return $this->applyFilter(Geo::searchNames($name, Geo::find($parent_id)));
		else
			return $this->applyFilter(Geo::searchNames($name));
	}
1368249
public function find($username)
    {
        $parameters['username'] = $username;
        return $this->apiClient->callEndpoint(self::ENDPOINT, $parameters);
    }
537924
public function findByRoleId($roleId)
    {
        $select = $this->getSelect($this->getUserTableName());
        $select->where(array($this->getTableName() . '.role_id' => $roleId));
        $select->join(
            $this->getTableName(),
            $this->getTableName(). '.user_id = ' . $this->getUserTableName(). '.user_id',
            array(),
            Select::JOIN_INNER
        );
        $select->group($this->getUserTableName(). '.user_id');

        $entityPrototype = $this->getZfcUserOptions()->getUserEntityClass();

        return $this->select($select, new $entityPrototype, $this->getZfcUserHydrator());
    }
248929
public static function findByNameType( $parentId, $parentType, $name, $type, $config = [] ) {

		return self::queryByNameType( $parentId, $parentType, $name, $type, $config )->one();
	}