This commit is contained in:
yumoqing 2026-03-20 17:18:45 +08:00
parent ce1d99e1bc
commit 7102c43a04

View File

@ -46,19 +46,17 @@ where a.id = c.userid
return path in paths return path in paths
async def is_user_has_path_perm(self, userid, path): async def is_user_has_path_perm(self, userid, path):
roles = None roles = self.ur_caches.get(userid)
if self.ur_caches is None: if userid is None:
roles = ['anonymous']
if self.rp_caches is None or not roles:
async with get_sor_context(env, 'rbac') as sor: async with get_sor_context(env, 'rbac') as sor:
await self.load_roleperms(sor) await self.load_roleperms(sor)
if userid:
roles = self.ur_caches.get(userid)
if not roles: if not roles:
await self.get_userroles(sor, userid) await self.get_userroles(sor, userid)
roles = self.ur_caches.get(userid) roles = self.ur_caches.get(userid)
if userid is None:
roles = ['anonymous']
return self.check_roles_path(roles, path) return self.check_roles_path(roles, path)