rbac/wwwroot/add_adminuser.dspy
2024-11-26 22:45:38 +08:00

24 lines
672 B
Plaintext

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)
user_orgid = await get_userorgid()
ns['orgid'] = user_orgid
dbname = await rfexe('get_module_dbname','rbac')
db = DBPools()
debug(f'{dbname=}')
async with db.sqlorContext(dbname) as sor:
await sor.C('users',ns.copy())
uid = ns['id']
ns = {
'id':uuid(),
'userid':uid,
'roleid':'admin'
}
await sor.C('userrole', ns.copy())
return UiMesage(title='Success', message='admin user added')
return UiError(title='Error', message='Error happened when add admin user')