Property for accessing :class:`UserManager` instance, which is used to manage users.

        :rtype: yagocd.resources.user.UserManager
508855
def users(self):
        
        if self._user_manager is None:
            self._user_manager = UserManager(session=self._session)
        return self._user_manager
28308
def get_user_info(self):
        
        response = self.get_proto(path='/user')
        message = yamcsManagement_pb2.UserInfo()
        message.ParseFromString(response.content)
        return UserInfo(message)
733797
def get_fields(self):
        
        ret = OrderedDict()

        # no rights to see anything
        if not self.user:
            return ret

        # all fields that can be accessed through serializer
        fields = super(ModelPermissionsSerializer, self).get_fields()

        # superuser can see all the fields
        if self.user.is_superuser:
            return fields

        # fields that can be accessed by auhtenticated user
        allowed_fields = self._get_user_allowed_fields()
        for allowed_field in allowed_fields:
            field = fields[allowed_field.name]

            # subfields are NestedModelSerializer
            if isinstance(field, ModelPermissionsSerializer):
                # no rights on subfield's fields
                # calculate how the relation should be retrieved
                if not field.get_fields():
                    field_cls = field._related_class
                    kwargs = get_relation_kwargs(allowed_field.name,
                                                 field.info)
                    if not issubclass(field_cls,
                                      serializers.HyperlinkedRelatedField):
                        kwargs.pop('view_name', None)
                    field = field_cls(**kwargs)

            ret[allowed_field.name] = field
        return ret
1191207
def create_lazy_user(self):
        
        user_class = self.model.get_user_class()
        username = self.generate_username(user_class)
        user = user_class.objects.create_user(username, '')
        self.create(user=user)
        return user, username
943187
def is_admin_user(self):
        
        user = api.user.get_current()
        roles = user.getRoles()
        return "LabManager" in roles or "Manager" in roles
167533
def get_user(self, username):
        
        User = get_user_model()  # noqa
        try:
            user = User.objects.get(**{
                User.USERNAME_FIELD: username,
                'is_active': False
            })
            return user
        except User.DoesNotExist:
            return None
332445
def get_user(self, user):
        
        self.project_service.set_auth(self._token_project)
        return self.project_service.get_user(user)
199765
def direct_perms_for_user(cls, instance, user, db_session=None):
        
        db_session = get_db_session(db_session, instance)
        query = db_session.query(
            cls.models_proxy.UserResourcePermission.user_id,
            cls.models_proxy.UserResourcePermission.perm_name,
        )
        query = query.filter(cls.models_proxy.UserResourcePermission.user_id == user.id)
        query = query.filter(
            cls.models_proxy.UserResourcePermission.resource_id == instance.resource_id
        )

        perms = [
            PermissionTuple(user, row.perm_name, "user", None, instance, False, True)
            for row in query
        ]

        # include all perms if user is the owner of this resource
        if instance.owner_user_id == user.id:
            perms.append(
                PermissionTuple(user, ALL_PERMISSIONS, "user", None, instance, True)
            )
        return perms
733866
def local_manager_gid(self):
        
        config = self.root['settings']['ugm_localmanager'].attrs
        user = security.authenticated_user(get_current_request())
        if not user:
            return None
        gids = user.group_ids
        adm_gids = list()
        for gid in gids:
            rule = config.get(gid)
            if rule:
                adm_gids.append(gid)
        if len(adm_gids) == 0:
            return None
        if len(adm_gids) > 1:
            msg = (u"Authenticated member defined in local manager "
                   u"groups %s but only one management group allowed for "
                   u"each user. Please contact System Administrator in "
                   u"order to fix this problem.")
            exc = msg % ', '.join(["'%s'" % gid for gid in adm_gids])
            raise Exception(exc)
        return adm_gids[0]
425566
def users(self):
        
        if not self.__users:
            self.__users = Users(self.__connection)
        return self.__users
698230
def get_permissions(self):
        
        user_role = self.last_login_role() if self.last_login_role_key else self.role_set[0].role
        return user_role.get_permissions()
998831
def assignee(self):
        
        if self.api and self.assignee_id:
            return self.api._get_user(self.assignee_id)
782968
def create_login_manager(self, app) -> LoginManager:
        
        lm = LoginManager(app)
        lm.login_view = "login"
        lm.user_loader(self.load_user)
        return lm
482373
def current_user(self):
        
        if not hasattr(self, '_serverInfo') or 'username' not in self._serverInfo:

            url = self._get_url('serverInfo')
            r = self._session.get(url, headers=self._options['headers'])

            r_json = json_loads(r)
            if 'x-ausername' in r.headers:
                r_json['username'] = r.headers['x-ausername']
            else:
                r_json['username'] = None
            self._serverInfo = r_json
            # del r_json['self']  # this isn't really an addressable resource
        return self._serverInfo['username']
819786
def user_patterns(self):
        
        # We do here some lazy loading.
        if not self._user_patterns:
            self._user_patterns = UserPatternManager(self)
        return self._user_patterns
149185
def ensure_compatible_admin(view):
    

    def wrapper(request, *args, **kwargs):
        user_roles = request.user.user_data.get('roles', [])
        if len(user_roles) != 1:
            context = {
                'message': 'I need to be able to manage user accounts. '
                           'My username is %s' % request.user.username
            }
            return render(request, 'mtp_common/user_admin/incompatible-admin.html', context=context)
        return view(request, *args, **kwargs)

    return wrapper
180957
def create_user(self, user):
        
        self.run("useradd -m %s" % user)
        usr =  getpwnam(user)
        return usr