Better SSO login experience

This commit is contained in:
Jiang Yio 2023-04-25 19:42:00 -04:00
parent 24291804a2
commit 132c85c1fd

10
rpc.py
View File

@ -140,7 +140,10 @@ class ClientSync(object):
return res
def authenticate(self, identity: str, *, context=('XUS SIGNON',)):
self._server.update(RecordServerInfo(*self('XUS SIGNON SETUP', '', '1', context=context))._asdict())
res = self('XUS AV CODE', XWBHash_encrypt(identity))
if identity.startswith('<?xml version="1.0" encoding="UTF-8"?>'):
res = self('XUS ESSO VALIDATE', RPCType(tuple(identity[i:i+200] for i in range(0, len(identity), 200)), RPCType.GLOBAL))
else:
res = self('XUS AV CODE', XWBHash_encrypt(identity))
if res[0] == '0' or res[2] != '0':
raise RPCExcAuth(res[3], res)
self._user = res
@ -217,7 +220,10 @@ class ClientAsync(object):
return res
async def authenticate(self, identity: str, *, context=('XUS SIGNON',)):
self._server.update(RecordServerInfo(*await self('XUS SIGNON SETUP', '', '1', context=context))._asdict())
res = await self('XUS AV CODE', XWBHash_encrypt(identity))
if identity.startswith('<?xml version="1.0" encoding="UTF-8"?>'):
res = await self('XUS ESSO VALIDATE', RPCType(tuple(identity[i:i+200] for i in range(0, len(identity), 200)), RPCType.GLOBAL))
else:
res = await self('XUS AV CODE', XWBHash_encrypt(identity))
if res[0] == '0' or res[2] != '0':
raise RPCExcAuth(res[3], res)
self._user = res