Get all local users.

        :param session: SQLAlchemy session
        :type session: :class:`sqlalchemy.Session`

        :return: local users
        :rtype: generator of :class:`pyshop.models.User`
779749
def get_locals(cls, session, **kwargs):
        
        return cls.find(session,
                        where=(cls.local == True,),
                        order_by=cls.login,
                        **kwargs)
391457
def get_valid_users(request):
    "
    users = [get_user(request)]
    if settings.LOCKDOWN and hasattr(request, 'user'):
        if request.user.is_authenticated:
            groups = request.user.groups.all()
            if groups:
                users = list(User.objects.filter(groups__in=groups)
                             .values_list('username', flat=True))
        else:
            # This may happen with crafted requests
            users = []
    return users
1337705
def session(self, create=True):
        
        if hasattr(self.local, 'session'):
            return self.local.session
        else:
            if create:
                s = Session(self.name)
                self.local.session = s
                return s
984919
def get_local_user(username):
    """"""
    try:
        _ = getpwnam(username)
        luser = username
    except KeyError:
        luser = getuser()
    return luser
1089537
def get_users(self):
        
        # We make use of the existing controlpanel `@@usergroup-userprefs`
        # view logic to make sure we get all users from all plugins (e.g. LDAP)
        users_view = UsersOverviewControlPanel(self.context, self.request)
        return users_view.doSearch("")
147661
def _retrieve_users(self):
        
        users_url = self._build_url('users')
        response = self._request('GET', users_url)
        users = response.json()
        return users
152546
def get_all_user_objects(self):
		
		logger.debug('Polling AD for all user objects')
		ldap_filter = r'(objectClass=user)'

		attributes = MSADUser.ATTRS
		for entry in self.pagedsearch(ldap_filter, attributes):
			# TODO: return ldapuser object
			yield MSADUser.from_ldap(entry, self._ldapinfo)
		logger.debug('Finished polling for entries!')
387369
def all(cls, domain=None):
        
        Site = cls
        site = Session.query(Site)
        if domain:
            site.filter(Site.domain == domain)
        return site.all()
322614
def get_user_from_session(session_key):
    
    session = Session.objects.get(session_key=session_key)
    session_data = session.get_decoded()
    uid = session_data.get('_auth_user_id')
    user = get_user_model().objects.filter(id=uid).first()  # get object or none
    return user
114307
def get_users(self, capacity=None):
        # type: (Optional[str]) -> List[User]
        
        users = list()
        usersdicts = self.data.get('users')
        if usersdicts is not None:
            for userdata in usersdicts:
                if capacity is not None and userdata['capacity'] != capacity:
                    continue
                id = userdata.get('id')
                if id is None:
                    id = userdata['name']
                user = hdx.data.user.User.read_from_hdx(id, configuration=self.configuration)
                user['capacity'] = userdata['capacity']
                users.append(user)
        return users
125462
def by_id(cls, user_id, db_session=None):
        
        db_session = get_db_session(db_session)
        query = db_session.query(cls.model)
        query = query.filter(cls.model.id == user_id)
        query = query.options(sa.orm.eagerload("groups"))
        return query.first()
269498
def by_user_names(cls, user_names, db_session=None):
        
        user_names = [(name or "").lower() for name in user_names]
        db_session = get_db_session(db_session)
        query = db_session.query(cls.model)
        query = query.filter(sa.func.lower(cls.model.user_name).in_(user_names))
        # q = q.options(sa.orm.eagerload(cls.groups))
        return query
407795
def list_users(self, user=None):
    '''
    ''' 
    from expfactory.database.models import Participant
    participants = Participant.query.all()
    users = []
    for user in participants:
        users.append(self.print_user(user))
    return users
1257769
def get_user(request):
    
    user = None
    try:
        user_id = request.session[SESSION_KEY]
        token = request.session[AUTH_TOKEN_SESSION_KEY]
        user_data = request.session[USER_DATA_SESSION_KEY]
        backend_path = request.session[BACKEND_SESSION_KEY]
    except KeyError:
        pass
    else:
        if backend_path in settings.AUTHENTICATION_BACKENDS:
            backend = load_backend(backend_path)
            user = backend.get_user(user_id, token, user_data)
            # Verify the session
            if hasattr(user, 'get_session_auth_hash'):
                session_hash = request.session.get(HASH_SESSION_KEY)
                session_hash_verified = session_hash and constant_time_compare(
                    session_hash,
                    user.get_session_auth_hash()
                )
                if not session_hash_verified:
                    request.session.flush()
                    user = None

    return user or MojAnonymousUser()
778762
def get(self):
        
        self._user = self._client.get(
            url=self._client.get_full_url(
                self.get_path(
                    'single', realm=self._realm_name, user_id=self._user_id
                )
            )
        )
        self._user_id = self.user["id"]
        return self._user
1269533
def _get_user(self) -> Dict:
        

        if 'callback_query' in self._update:
            return self._update['callback_query']['from']
        elif 'inline_query' in self._update:
            return self._update['inline_query']['from']
        elif 'message' in self._update:
            return self._update['message']['from']
1271366
def session(self, auth=None):
        
        url = '{server}{auth_url}'.format(**self._options)

        if isinstance(self._session.auth, tuple) or auth:
            if not auth:
                auth = self._session.auth
            username, password = auth
            authentication_data = {'username': username, 'password': password}
            r = self._session.post(url, data=json.dumps(authentication_data))
        else:
            r = self._session.get(url)

        user = User(self._options, self._session, json_loads(r))
        return user