rbac/wwwroot/add_adminuser.dspy

24 lines
672 B
Plaintext
Raw Normal View History

2024-11-10 15:01:02 +08:00
if params_kw.get('password') != params_kw.get('chkpassword'):
return Error(title='add user error', message='password not match')
ns = params_kw.copy()
ns['id'] = uuid()
await rfexe('passowrd', ns)
2024-11-26 22:45:38 +08:00
user_orgid = await get_userorgid()
2024-11-10 15:01:02 +08:00
ns['orgid'] = user_orgid
2024-11-26 22:45:38 +08:00
dbname = await rfexe('get_module_dbname','rbac')
db = DBPools()
debug(f'{dbname=}')
async with db.sqlorContext(dbname) as sor:
2024-11-10 15:01:02 +08:00
await sor.C('users',ns.copy())
uid = ns['id']
ns = {
'id':uuid(),
'userid':uid,
'roleid':'admin'
}
await sor.C('userrole', ns.copy())
2024-11-26 22:45:38 +08:00
return UiMesage(title='Success', message='admin user added')
return UiError(title='Error', message='Error happened when add admin user')