This commit is contained in:
yumoqing 2026-03-21 11:41:03 +08:00
parent 3d38d97676
commit b7c71bda18

View File

@ -1104,24 +1104,25 @@ async def add_roleperm(sor, roleid, permid):
async def add_roles_perm(perm, roles): async def add_roles_perm(perm, roles):
perms = [perm] perms = [perm]
if role in ['anonymous', 'any', 'logined']: for role in roles:
for p in perms: if role in ['anonymous', 'any', 'logined']:
await add_roleperm(sor, role, p.id) for p in perms:
return await add_roleperm(sor, role, p.id)
orgtypeid, name = role.split('.') continue
ns = { orgtypeid, name = role.split('.')
'orgtypeid': orgtypeid, ns = {
'name': name 'orgtypeid': orgtypeid,
} 'name': name
roles = await sor.R('role', ns.copy()) }
if not roles: roles = await sor.R('role', ns.copy())
ns['id'] = getID() if not roles:
await sor.C('role', ns.copy()) ns['id'] = getID()
else: await sor.C('role', ns.copy())
else:
ns['id'] = roles[0].id ns['id'] = roles[0].id
for p in perms: for p in perms:
await add_roleperm(sor, ns['id'], p.id) await add_roleperm(sor, ns['id'], p.id)
await delete_anonymous_perm(sor, p.id) await delete_anonymous_perm(sor, p.id)
async def main(): async def main():
config = getConfig('.') config = getConfig('.')