(id, cmd, args)
| 125 | |
| 126 | # {login} |
| 127 | def loginMsg(id, cmd, args): |
| 128 | if cmd.secret == None: |
| 129 | if cmd.uname == None: |
| 130 | cmd.uname = '' |
| 131 | if cmd.password == None: |
| 132 | cmd.password = '' |
| 133 | cmd.secret = str(cmd.uname) + ":" + str(cmd.password) |
| 134 | cmd.secret = cmd.secret.encode('utf-8') |
| 135 | elif cmd.scheme == "basic": |
| 136 | # Assuming secret is a uname:password string. |
| 137 | cmd.secret = str(cmd.secret).encode('utf-8') |
| 138 | else: |
| 139 | # All other schemes: assume secret is a base64-encoded string |
| 140 | cmd.secret = base64.b64decode(cmd.secret) |
| 141 | |
| 142 | from client import handle_login, save_cookie |
| 143 | msg = pb.ClientMsg(login=pb.ClientLogin(id=str(id), scheme=cmd.scheme, secret=cmd.secret, |
| 144 | cred=parse_cred(cmd.cred))) |
| 145 | |
| 146 | if args.no_cookie or not tn_globals.IsInteractive: |
| 147 | tn_globals.OnCompletion[str(id)] = lambda params: handle_login(params) |
| 148 | else: |
| 149 | tn_globals.OnCompletion[str(id)] = lambda params: save_cookie(params) |
| 150 | |
| 151 | return msg |
| 152 | |
| 153 | |
| 154 | # {sub} |
no test coverage detected
searching dependent graphs…