Search users based on a provided string
774418
function searchUsers(searchStr){
    console.log('getUsers called');
    if(!searchStr){
      searchStr = document.getElementById('search').value;
    }
    grout.Users.search(searchStr).then(function(users){
      console.log('search users loaded:', users);
      document.getElementById("search-output").innerHTML = JSON.stringify(users);
    });
  }
493555
def get_by_id(self, id):
        """"""
        with contextlib.closing(self.database.cursor()) as cursor:
            cursor.execute('SELECT id, name FROM users WHERE id=?', (id,))
            return cursor.fetchone()
369539
def process_user(ctx, param, value):
    """"""
    if value:
        if value.isdigit():
            user = User.query.get(str(value))
        else:
            user = User.query.filter(User.email == value).one_or_none()
        return user
1155234
def search(query, params = {})
      params = URI.escape(params.collect{|k,v| "#{k}=#{v}"}.join('&')).insert 0, "&"
      get("search/?q=#{query}#{params}")['sections'][0]['rows']
    end
552044
@Override
    public List<User> searchUsers(String search) throws AuthenticationException {
        // Complete list of users
        String[] users = file_store.keySet().toArray(
                new String[file_store.size()]);
        List<User> found = new ArrayList<User>();

        // Look through the list for anyone who matches
        for (int i = 0; i < users.length; i++) {
            if (users[i].toLowerCase().contains(search.toLowerCase())) {
                found.add(getUser(users[i]));
            }
        }

        // Return the list
        return found;
    }
344490
def is_username(string, minlen=1, maxlen=15):
    
    if string:
        string = string.strip()
        return username_re.match(string) and (minlen <= len(string) <= maxlen)
    return False
96503
def query(self,query_string,toprint=False):
		""""""
		qq=SearchTerm(query_string)
		matchcount=0
		matches=[]
		for word in self.words():
			for match in word.search(qq):
				matches.append(match)
				matchcount+=1
				if "Word" in str(type(match)):
					matchstr=""
				else:
					matchstr=str(match)
				if toprint:
					word.om(makeminlength(str(matchcount),int(being.linelen/6))+"\t"+makeminlength(str(word),int(being.linelen))+"\t"+matchstr)
		return matches
338053
def search(self, event):
        """"""

        try:
            data, schema, user, client = self._get_args(event)
        except AttributeError:
            return

        # object_filter['$text'] = {'$search': str(data['search'])}
        if data.get('fulltext', False) is True:
            object_filter = {
                'name': {
                    '$regex': str(data['search']),
                    '$options': '$i'
                }
            }
        else:
            if isinstance(data['search'], dict):
                object_filter = data['search']
            else:
                object_filter = {}

        if 'fields' in data:
            fields = data['fields']
        else:
            fields = []

        skip = data.get('skip', 0)
        limit = data.get('limit', 0)
        sort = data.get('sort', None)
        # page = data.get('page', 0)
        # count = data.get('count', 0)
        #
        # if page > 0 and count > 0:
        #     skip = page * count
        #     limit = count

        if 'subscribe' in data:
            self.log('Subscription:', data['subscribe'], lvl=verbose)
            do_subscribe = data['subscribe'] is True
        else:
            do_subscribe = False

        object_list = []

        size = objectmodels[schema].count(object_filter)

        if size > WARNSIZE and (limit > 0 and limit > WARNSIZE):
            self.log("Getting a very long (", size, ") list of items for ", schema,
                     lvl=warn)

        opts = schemastore[schema].get('options', {})
        hidden = opts.get('hidden', [])

        self.log("object_filter: ", object_filter, ' Schema: ', schema,
                 "Fields: ", fields,
                 lvl=verbose)

        options = {}
        if skip > 0:
            options['skip'] = skip
        if limit > 0:
            options['limit'] = limit
        if sort is not None:
            options['sort'] = []
            for item in sort:
                key = item[0]
                direction = item[1]
                direction = ASCENDING if direction == 'asc' else DESCENDING
                options['sort'].append([key, direction])

        cursor = objectmodels[schema].find(object_filter, **options)

        for item in cursor:
            if not self._check_permissions(user, 'list', item):
                continue
            self.log("Search found item: ", item, lvl=verbose)

            try:
                list_item = {'uuid': item.uuid}
                if fields in ('*', ['*']):
                    item_fields = item.serializablefields()
                    for field in hidden:
                        item_fields.pop(field, None)
                    object_list.append(item_fields)
                else:
                    if 'name' in item._fields:
                        list_item['name'] = item.name

                    for field in fields:
                        if field in item._fields and field not in hidden:
                            list_item[field] = item._fields[field]
                        else:
                            list_item[field] = None

                    object_list.append(list_item)

                if do_subscribe:
                    self._add_subscription(item.uuid, event)
            except Exception as e:
                self.log("Faulty object or field: ", e, type(e),
                         item._fields, fields, lvl=error, exc=True)
        # self.log("Generated object search list: ", object_list)

        result = {
            'component': 'hfos.events.objectmanager',
            'action': 'search',
            'data': {
                'schema': schema,
                'list': object_list,
                'size': size
            }
        }

        self._respond(None, result, event)
481690
function findByUsernamePassword(username, password, strict, callback) {
  if (typeof strict === 'function') {
    callback = strict;
    strict = true;
  }

  return this.findByUsername(username, strict, ok(callback, (user) => {
    if (!user) {
      return callback(null, null);
    }

    user.comparePassword(password, ok(callback, (isMatch) => {
      if (!isMatch) {
        return callback(null, null);
      }

      callback(null, user);
    }));
  }));
}
1282857
def user_search(auth=None, **kwargs):
    '''
    
    '''
    cloud = get_openstack_cloud(auth)
    kwargs = _clean_kwargs(**kwargs)
    return cloud.search_users(**kwargs)
1112864
def _get_user(self, user):
        """"""
        return ' '.join([user.username, user.first_name, user.last_name])
17885
def _parse_users(self, match):
        ''''''

        # Don't parse lists here
        if match.group(2) is not None:
            return match.group(0)

        mat = match.group(0)
        if self._include_spans:
            self._users.append((mat[1:], match.span(0)))
        else:
            self._users.append(mat[1:])

        if self._html:
            return self.format_username(mat[0:1], mat[1:])
278544
def search(query)
        clause = query.blank? ? nil : "%" + query.downcase + "%"
        base = ::User.where(*base_query)
        base = base.where("#{Hydra.config.user_key_field} like lower(?) OR display_name like lower(?)", clause, clause) if clause.present?
        base.registered
            .where("#{Hydra.config.user_key_field} not in (?)",
                   [::User.batch_user_key, ::User.audit_user_key])
            .references(:trophies)
            .order(sort_value)
            .page(params[:page]).per(10)
      end
251991
def search
      user = User.where("email = ? AND id != ?", params[:email], @user.id).first
      if user
        render json: user
      else
        render json: {}, status: :not_found
      end
    end
743297
def user_info(name, **client_args):
    '''
    
    '''
    matching_users = (user for user in list_users(**client_args)
                      if user.get('user') == name)

    try:
        return next(matching_users)
    except StopIteration:
        pass
1242674
def process_email(ctx, param, value):
    """"""
    user = User.query.filter(User.email == value).first()
    if not user:
        raise click.BadParameter('User with email \'%s\' not found.', value)
    return user
1106060
@Action(
            domainEvent = FindUsersByNameDomainEvent.class,
            semantics = SemanticsOf.SAFE
    )
    @MemberOrder(sequence = "100.10.2")
    public List<ApplicationUser> findUsers(
            final @ParameterLayout(named = "Search") String search) {
        return applicationUserRepository.find(search);
    }