This commit is contained in:
yumoqing 2024-11-11 16:09:35 +08:00
parent 59d517cbd5
commit f4b66212d5

View File

@ -31,20 +31,20 @@ async def get_session_userinfo(request):
d = await auth.get_auth(request)
if d is None:
return DictObject()
info = d.split(':')
ui = d.split(':')
return DictObject(**{
'userid':info[0],
'username':info[1],
'userorgid':info[2]
'userid':ui[0],
'username':ui[1],
'userorgid':ui[2]
})
async def get_session_user(request):
userinfo = await get_session_userinfo(request)
return userinfo.userid
return userinfo.user
async def user_login(request, userid, username='', userorgid=''):
info = f'{userid}:{username}:{userorgid}'
await auth.remember(request, info)
ui = f'{userid}:{username}:{userorgid}'
await auth.remember(request, ui)
async def user_logout(request):
await auth.forget(request)
@ -151,8 +151,8 @@ class AuthAPI:
info(f'checkAuth() called ... {request.path=}')
t1 = time.time()
path = request.path
info = await get_session_userinfo(request)
user = info.userid
userinfo = await get_session_userinfo(request)
user = userinfo.userid
is_ok = await self.checkUserPermission(user, path)
t2 = time.time()
ip = get_client_ip(None, request)