Compare commits

..

No commits in common. "50892fc3d28fc54363e5ca8361c1f6f4710582d5" and "ebd678a43d753f93bbfd4478cde8068721110f43" have entirely different histories.

View File

@ -172,38 +172,15 @@ where a.id = c.userid
self.ur_caches.set(userid, sorted(list(set(roles))))
def check_roles_path(self, roles, path):
"""Check if any of the roles has access to the given path.
Supports:
- Exact match: '/customer_management/index.ui' or '/main/login.ui'
- Wildcard prefix match: '/customer_management/**' matches any path starting with '/customer_management/'
- Path normalization: tries both the raw path and path with /main stripped
"""
"""Check if any of the roles has access to the given path."""
ret = False
for role in roles:
paths = self.rp_caches.get(role)
if not paths:
continue
# Try exact match with raw path
if path in paths:
return True
# Try with /main prefix stripped: /main/xxx -> /xxx
if path.startswith('/main/'):
normalized = '/' + path[6:]
if normalized in paths:
return True
# Also try wildcard match with normalized path
for perm_path in paths:
if perm_path.endswith('**'):
prefix = perm_path[:-2]
if normalized.startswith(prefix) or path.startswith(prefix):
return True
# Wildcard prefix match with raw path
for perm_path in paths:
if perm_path.endswith('**'):
prefix = perm_path[:-2]
if path.startswith(prefix):
return True
return False
return ret
async def is_user_has_path_perm(self, userid, path):
"""Check if a user has permission for the given path.