Returns the list of features that are enabled for the user.

    Args:
      user_id: ID for user.
      attributes: Dict representing user attributes.

    Returns:
      A list of the keys of the features that are enabled for the user.
328876
def get_enabled_features(self, user_id, attributes=None):
    

    enabled_features = []
    if not self.is_valid:
      self.logger.error(enums.Errors.INVALID_DATAFILE.format('get_enabled_features'))
      return enabled_features

    if not isinstance(user_id, string_types):
      self.logger.error(enums.Errors.INVALID_INPUT_ERROR.format('user_id'))
      return enabled_features

    if not self._validate_user_inputs(attributes):
      return enabled_features

    for feature in self.config.feature_key_map.values():
      if self.is_feature_enabled(feature.key, user_id, attributes):
        enabled_features.append(feature.key)

    return enabled_features
1054999
async def list(cls, user_id: Union[int, str] = None,
                   is_active: bool = None,
                   fields: Iterable[str] = None) -> Sequence[dict]:
        '''
        
        '''
        if fields is None:
            fields = (
                'access_key', 'secret_key',
                'is_active', 'is_admin',
            )
        if user_id is None:
            q = 'query($is_active: Boolean) {' \
                '  keypairs(is_active: $is_active) {' \
                '    $fields' \
                '  }' \
                '}'
        else:
            uid_type = 'Int!' if isinstance(user_id, int) else 'String!'
            q = 'query($user_id: {0}, $is_active: Boolean) {{'.format(uid_type) + \
                '  keypairs(user_id: $user_id, is_active: $is_active) {' \
                '    $fields' \
                '  }' \
                '}'
        q = q.replace('$fields', ' '.join(fields))
        variables = {
            'is_active': is_active,
        }
        if user_id is not None:
            variables['user_id'] = user_id
        rqst = Request(cls.session, 'POST', '/admin/graphql')
        rqst.set_json({
            'query': q,
            'variables': variables,
        })
        async with rqst.fetch() as resp:
            data = await resp.json()
            return data['keypairs']
115342
def user(self):
        
        if self.api and self.user_id:
            return self.api._get_user(self.user_id)
328526
def get_userid_presence(self, user_id: str) -> UserPresence:
        
        return self._userid_to_presence.get(user_id, UserPresence.UNKNOWN)
760672
def get_security_attributes_for_user(user=None):
	
	if user is None:
		user = get_current_user()

	assert isinstance(user, security.TOKEN_USER), (
		"user must be TOKEN_USER instance")

	SD = security.SECURITY_DESCRIPTOR()
	SA = security.SECURITY_ATTRIBUTES()
	# by attaching the actual security descriptor, it will be garbage-
	# collected with the security attributes
	SA.descriptor = SD
	SA.bInheritHandle = 1

	ctypes.windll.advapi32.InitializeSecurityDescriptor(
		ctypes.byref(SD),
		security.SECURITY_DESCRIPTOR.REVISION)
	ctypes.windll.advapi32.SetSecurityDescriptorOwner(
		ctypes.byref(SD),
		user.SID, 0)
	return SA
977300
def list_roles_for_user(self, user):
        
        user_id = utils.get_id(user)
        uri = "users/%s/roles" % user_id
        resp, resp_body = self.method_get(uri)
        if resp.status_code in (401, 403):
            raise exc.AuthorizationFailure("You are not authorized to list "
                    "user roles.")
        roles = resp_body.get("roles")
        return roles
814193
def user_bindings(self):
        
        if self._user_bindings is None:
            self._user_bindings = UserBindingList(
                self._version,
                service_sid=self._solution['service_sid'],
                user_sid=self._solution['sid'],
            )
        return self._user_bindings
1084106
def getFeatureSet(self, id_):
        
        if id_ not in self._featureSetIdMap:
            raise exceptions.FeatureSetNotFoundException(id_)
        return self._featureSetIdMap[id_]
237391
def get_user_id(self, user_id, mount_point='app-id', wrap_ttl=None):
        
        path = '/v1/auth/{0}/map/user-id/{1}'.format(mount_point, user_id)
        return self._adapter.get(path, wrap_ttl=wrap_ttl).json()
680696
def find_nameid(self, userid, **kwargs):
        
        res = []
        try:
            _vals = self.db[userid]
        except KeyError:
            logger.debug("failed to find userid %s in IdentDB", userid)
            return res

        for val in _vals.split(" "):
            nid = decode(val)
            if kwargs:
                for key, _val in kwargs.items():
                    if getattr(nid, key, None) != _val:
                        break
                else:
                    res.append(nid)
            else:
                res.append(nid)

        return res
307560
def list_members(self, list_id):
        
        return [User(user._json) for user in self._client.list_members(list_id=list_id)]
421385
def _get_context_and_user_ids(self, context_name, user_name):
        """"""
        if context_name is None:
            return None, None

        context_id = self.get_context_info(context_name)['id']
        user_id = None
        if user_name:
            user_id = self._get_user_id_from_name(context_id, user_name)

        return context_id, user_id
835661
def get_user_properties(user_or_username):
    
    user = get_user(user_or_username)
    if user is None:
        return {}
    if not callable(user.getUser):
        return {}
    out = {}
    plone_user = user.getUser()
    for sheet in plone_user.listPropertysheets():
        ps = plone_user.getPropertysheet(sheet)
        out.update(dict(ps.propertyItems()))
    return out
135185
def delete_user_entitlements(self, user_id):
        
        route_values = {}
        if user_id is not None:
            route_values['userId'] = self._serialize.url('user_id', user_id, 'str')
        self._send(http_method='DELETE',
                   location_id='6490e566-b299-49a7-a4e4-28749752581f',
                   version='5.1-preview.1',
                   route_values=route_values)
721808
def get_user_info(self, user_id, **kwargs):
        
        return GetUserInfo(settings=self.settings, **kwargs).call(
            user_id=user_id,
            **kwargs
        )
946948
def user_model_attributes(user, service):
    
    ignore_fields = ['id', 'password']
    attributes = {}
    for field in user._meta.fields:
        if field.name not in ignore_fields:
            attributes[field.name] = getattr(user, field.name)
    return attributes
531029
def user(id)
      if id
        cached_user = users.detect {|u| u[:id] == id }
        user = cached_user || fetch_user(id)
        self.users << user
        user
      end
    end