Returns a dict that represents the user who prints the ws
            Keys: username, fullname, email
1334
def _printedby_data(self, ws):
        
        data = {}
        member = self.context.portal_membership.getAuthenticatedMember()
        if member:
            username = member.getUserName()
            data['username'] = username
            data['fullname'] = to_utf8(self.user_fullname(username))
            data['email'] = to_utf8(self.user_email(username))

            c = [x for x in self.bika_setup_catalog(portal_type='LabContact')
                 if x.getObject().getUsername() == username]
            if c:
                sf = c[0].getObject().getSignature()
                if sf:
                    data['signature'] = sf.absolute_url() + "/Signature"

        return data
1294110
def dict(self):
        

        d = {p.key: getattr(self, p.key) for p in self.__mapper__.attrs if p.key not in ('data')}

        d['secret'] = 'not available'

        if self.secret_password:
            try:
                d['secret'] = self.decrypt_secret()
            except AccountDecryptionError:
                pass

        if self.data:
            for k, v in self.data.items():
                d[k] = v

        return {k: v for k, v in d.items()}
941089
def _user_raw_from_login_content(login_content):
    """"""
    matching_keys = [
        'displayName',
        'lastLogin',
        'active',
        'name',
        'isMe',
        'lastPasswordChangedDate',
        'passwordResetRequired',
        'groups',
        'roles',
        'email',
        'isAdmin',
        'createdDate',
        'modifiedDate',
        'createdByUser',
        'modifiedByUser',
        'userName',
        'id',
        'disabled'
    ]

    raw_data = {
        '$type': User._type,
    }

    for key in matching_keys:
        if key in login_content:
            raw_data[key] = login_content[key]

    return raw_data
530976
def userToJson(user):
    
    obj = {
        'id': user.id,
        'username': user.username,
        'name': user.get_full_name(),
        'email': user.email,
    }

    return obj
626714
def authnkey(self) -> dict:
        

        return {k: self._pubkey[k] for k in self._pubkey if self._pubkey[k].authn}
857283
def getHeaders(self):
        
        basicauth = base64.encodestring(b(self.user + ':' + self.password)).strip()
        return {
            "Depth": "1",
            "Authorization": 'Basic ' + _decode_utf8(basicauth),
            "Accept": "*/*"
        }
131001
def creds(self):
        
        session = self.client.session()
        if session is None:
            return None

        return {
            "basic_auth": self.client.basic_auth_str(),
            "user_ctx": session.get('userCtx')
        }
1337889
def _getUsername(self):
        
        for (l, d) in getAccountNames(self.store):
            return l + u'@' + d
676347
def get_user_creds(username, password):
    
    username = utils.first_true(
        [username, config["bel_api"]["servers"]["arangodb_username"]], default=""
    )
    password = utils.first_true(
        [password, config["secrets"]["bel_api"]["servers"].get("arangodb_password")],
        default="",
    )

    return username, password
1085539
def name(self):
        
        if hasattr(self.user, "get_full_name"):
            return self.user.get_full_name()
        return "{0}".format(self.user)
1310719
def get_user_details(self, response):
        
        result = {
            'username': response[self.ENV_USERNAME],
            'email': response.get(self.ENV_EMAIL, None),
            'first_name': response.get(self.ENV_FIRST_NAME, None),
            'last_name': response.get(self.ENV_LAST_NAME, None)
        }
        if result['first_name'] and result['last_name']:
            result['fullname']=result['first_name']+' '+result['last_name']
        logger.debug("Returning user details: "+str(result))
        return result
474383
def write_users(dburl):
    """"""
    data = {
        'username': 'admin',
        'realname': 'Website Administrator',
        'email': 'coil@example.com',
        'password':
            r'$bcrypt-sha256$2a,12$NNtd2TC9mZO6.EvLwEwlLO$axojD34/iE8x'
            r'QitQnCCOGPhofgmjNdq',
    }

    for p in PERMISSIONS:
        data[p] = '1'

    db = redis.StrictRedis.from_url(dburl)
    db.hmset('user:1', data)
    db.hset('users', 'admin', '1')
    if not db.exists('last_uid'):
        db.incr('last_uid')

    print("Username: admin")
    print("Password: admin")
    return 0
406101
def get_user_name(user, full_name=True):
     # noqa
    try:
        if full_name:
            name = ' '.join([user.first_name, user.last_name])
        else:
            name = user.first_name
    except AttributeError:
        name = None

    return name
789272
def list_users(self):
        
        crypt = self._decrypt_file()

        self.logger.info(crypt.stderr)
        raw_userlist = crypt.stderr.split('\n')
        userlist = list()
        for index, line in enumerate(raw_userlist):
            if 'gpg: encrypted' in line:
                m = re.search('ID (\w+)', line)
                keyid = m.group(1).strip()
                userline = raw_userlist[index+1].strip()
                userlist.append((keyid, userline))
        return userlist
418363
def get_group_dict(user=None, include_default=True):
    '''
    
    '''
    if HAS_GRP is False or HAS_PWD is False:
        return {}
    group_dict = {}
    group_names = get_group_list(user, include_default=include_default)
    for group in group_names:
        group_dict.update({group: grp.getgrnam(group).gr_gid})
    return group_dict
1234691
def _whoami():
    # type: () -> Tuple[Text,Text]
    """"""
    username = getuser()
    try:
        if onWindows():
            get_user_name = ctypes.windll.secur32.GetUserNameExW  # type: ignore
            size = ctypes.pointer(ctypes.c_ulong(0))
            get_user_name(3, None, size)

            name_buffer = ctypes.create_unicode_buffer(size.contents.value)
            get_user_name(3, name_buffer, size)
            fullname = str(name_buffer.value)
        else:
            fullname = pwd.getpwuid(os.getuid())[4].split(',')[0]
    except (KeyError, IndexError):
        fullname = username

    return (username, fullname)
922426
def getusers(self, userlist):
        
        userobjs = [User(self, **rawuser) for rawuser in
                    self._getusers(names=userlist).get('users', [])]

        # Return users in same order they were passed in
        ret = []
        for u in userlist:
            for uobj in userobjs[:]:
                if uobj.email == u:
                    userobjs.remove(uobj)
                    ret.append(uobj)
                    break
        ret += userobjs
        return ret