fix: check permission table

This commit is contained in:
ymq 2026-08-12 12:07:52 +08:00
parent fa9e37af51
commit 8ead5e19eb

View File

@ -2,10 +2,18 @@
dbname = get_module_dbname('rbac')
async with DBPools().sqlorContext(dbname) as sor:
recs = await sor.sqlExe("SELECT * FROM rolepermission WHERE roleid='any' LIMIT 3", {})
# Get all 'any' role permissions
rp = await sor.sqlExe("SELECT permid FROM rolepermission WHERE roleid='any'", {})
permids = [getattr(r, "permid", "") for r in (rp or [])]
# Check permission table for these IDs
result = []
for r in (recs or []):
d = r.to_dict() if hasattr(r, 'to_dict') else {}
result.append(d)
for pid in permids[:10]:
perm = await sor.sqlExe("SELECT * FROM permission WHERE id=${p}$", {"p": pid})
if perm:
d = perm[0].to_dict() if hasattr(perm[0], 'to_dict') else {}
result.append(d)
else:
result.append({"permid": pid, "error": "not found"})
return json.dumps({"any_perms": result}, ensure_ascii=False, default=str)
return json.dumps({"perm_count": len(permids), "sample": result}, ensure_ascii=False, default=str)