From feeab18bc54ca4f69170fd3dbb319fcba06f66c1 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 6 Nov 2024 15:55:43 +0800 Subject: [PATCH] bugfix --- ahserver/auth_api.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ahserver/auth_api.py b/ahserver/auth_api.py index 3967e5e..c2ca1e1 100755 --- a/ahserver/auth_api.py +++ b/ahserver/auth_api.py @@ -28,7 +28,10 @@ def get_client_ip(obj, request): return ip async def get_session_userinfo(request): - info = await auth.get_auth(request).split(':') + d = await auth.get_auth(request) + if d is None: + return DictObject() + info = d.split(':') return DictObject(**{ 'userid':info[0], 'username':info[1], @@ -36,12 +39,12 @@ async def get_session_userinfo(request): }) async def get_session_user(request): - userid = await get_session_userinfo(request).userid - return userid + userinfo = await get_session_userinfo(request) + return userinfo.userid async def user_login(request, userid, username='', userorgid=''): info = f'{userid}:{username}:{userorgid}' - await auth.remember(request, userinfo) + await auth.remember(request, info) async def user_logout(request): await auth.forget(request)