示例#1
0
def accMsg(id, cmd, ignored):
    if cmd.uname:
        cmd.scheme = 'basic'
        if cmd.password == None:
            cmd.password = ''
        cmd.secret = str(cmd.uname) + ":" + str(cmd.password)

    if cmd.secret:
        if cmd.scheme == None:
            cmd.scheme = 'basic'
        cmd.secret = cmd.secret.encode('utf-8')
    else:
        cmd.secret = b''

    state = None
    if cmd.suspend == 'true':
        state = 'susp'
    elif cmd.suspend == 'false':
        state = 'ok'

    cmd.public = encode_to_bytes(make_vcard(cmd.fn, cmd.photo))
    cmd.private = encode_to_bytes(cmd.private)
    return pb.ClientMsg(acc=pb.ClientAcc(id=str(id), user_id=cmd.user, state=state,
        scheme=cmd.scheme, secret=cmd.secret, login=cmd.do_login, tags=cmd.tags.split(",") if cmd.tags else None,
        desc=pb.SetDesc(default_acs=pb.DefaultAcsMode(auth=cmd.auth, anon=cmd.anon),
            public=cmd.public, private=cmd.private),
        cred=parse_cred(cmd.cred)), on_behalf_of=tn_globals.DefaultUser)
示例#2
0
def accMsg(id, user, scheme, secret, uname, password, do_login, fn, photo,
           private, auth, anon, tags, cred):
    if secret == None and uname != None:
        if password == None:
            password = ''
        secret = str(uname) + ":" + str(password)
    if secret:
        secret = secret.encode('utf-8')
    else:
        secret = b''
    print(default_user)
    public = encode_to_bytes(make_vcard(fn, photo)) if (fn or photo) else None
    private = encode_to_bytes(private) if private else None
    return pb.ClientMsg(acc=pb.ClientAcc(
        id=str(id),
        user_id=user,
        scheme=scheme,
        secret=secret,
        login=do_login,
        tags=tags.split(",") if tags else None,
        desc=pb.SetDesc(default_acs=pb.DefaultAcsMode(auth=auth, anon=anon),
                        public=public,
                        private=private),
        cred=parse_cred(cred)),
                        on_behalf_of=default_user)