bugfix
This commit is contained in:
parent
4521bcb143
commit
0855761d34
@ -1,3 +1,3 @@
|
|||||||
#!/usr/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
xls2ui -m ../models -o ../wwwroot rbac *.json
|
xls2ui -m ../models -o ../wwwroot rbac *.json
|
||||||
|
@ -55,25 +55,48 @@ async def get_user_roles(userid):
|
|||||||
roles.append(r.name)
|
roles.append(r.name)
|
||||||
return roles
|
return roles
|
||||||
|
|
||||||
async def create_org(sor, ns):
|
async def create_org(sor, ns, orgtypes=[]):
|
||||||
await sor.C('organization', ns)
|
await sor.C('organization', ns)
|
||||||
otns = {
|
if orgtypes == []:
|
||||||
'id':getID(),
|
orgtypes = ['customer']
|
||||||
'orgid':ns.id,
|
if 'customer' not in orgtypes:
|
||||||
'orgtypeid':'customer'
|
orgtypes.append('customer')
|
||||||
}
|
for ot in orgtypes:
|
||||||
await sor.C('orgtypes', otns)
|
otns = {
|
||||||
|
'id':getID(),
|
||||||
|
'orgid':ns.id,
|
||||||
|
'orgtypeid':ot
|
||||||
|
}
|
||||||
|
await sor.C('orgtypes', otns)
|
||||||
|
|
||||||
async def create_user(sor, ns):
|
async def create_user(sor, ns, roles=[]):
|
||||||
|
"""
|
||||||
|
role format:
|
||||||
|
{
|
||||||
|
orgtypeid: rr,
|
||||||
|
roles: ['ee', 'bb']
|
||||||
|
}
|
||||||
|
"""
|
||||||
await sor.C('users', ns)
|
await sor.C('users', ns)
|
||||||
sql = "select * from role where orgtypeid = 'customer' and name in ('admin', 'customer')"
|
if roles == []:
|
||||||
recs = await sor.sqlExe(sql, {})
|
roles = [
|
||||||
for r in recs:
|
{
|
||||||
await sor.C('userrole', {
|
'orgtypeid': 'customer',
|
||||||
'id':getID(),
|
'roles': [ 'customer']
|
||||||
'userid':ns.id,
|
}
|
||||||
'roleid':r.id
|
]
|
||||||
})
|
for rt in roles:
|
||||||
|
sql = "select * from role where orgtypeid = ${otid}$ and name in ${roles}$)"
|
||||||
|
recs = await sor.sqlExe(sql, {
|
||||||
|
'otid': rt['orgtypeid',
|
||||||
|
'roles': rt['roles']
|
||||||
|
})
|
||||||
|
for r in recs:
|
||||||
|
await sor.C('userrole', {
|
||||||
|
'id':getID(),
|
||||||
|
'userid':ns.id,
|
||||||
|
'roleid':r.id
|
||||||
|
})
|
||||||
|
|
||||||
async def register_user(sor, ns):
|
async def register_user(sor, ns):
|
||||||
if ns.password != ns.cfm_password:
|
if ns.password != ns.cfm_password:
|
||||||
|
Loading…
Reference in New Issue
Block a user