fix: add id to userrole insert + remove manual created_at (DB has defaults)
This commit is contained in:
parent
fb579cbd2f
commit
fac526637b
@ -26,9 +26,8 @@ async with DBPools().sqlorContext('sage') as sor_sage:
|
||||
'SELECT id FROM organization WHERE id = ${oid}$', {'oid': org_id}
|
||||
)
|
||||
if not org_recs:
|
||||
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
await sor_sage.C('organization', {
|
||||
'id': org_id, 'orgname': sd.sub_dist_name, 'create_at': now,
|
||||
'id': org_id, 'orgname': sd.sub_dist_name,
|
||||
})
|
||||
|
||||
# Check if admin already exists
|
||||
@ -47,14 +46,13 @@ async with DBPools().sqlorContext('sage') as sor_sage:
|
||||
|
||||
# Generate password from uuid
|
||||
pwd = getID().replace('-','')[:12]
|
||||
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
user_id = getID()
|
||||
|
||||
await sor_sage.C('users', {
|
||||
'id': user_id, 'username': admin_username,
|
||||
'password': password_encode(pwd),
|
||||
'orgid': org_id, 'nick_name': sd.sub_dist_name + '管理员',
|
||||
'user_status': '1', 'created_at': now,
|
||||
'user_status': '1',
|
||||
})
|
||||
|
||||
# Assign roles: logined + reseller.admin + reseller.operator
|
||||
@ -62,7 +60,7 @@ async with DBPools().sqlorContext('sage') as sor_sage:
|
||||
role_recs = await sor_sage.R('role', {'role': role_name})
|
||||
if role_recs:
|
||||
await sor_sage.C('userrole', {
|
||||
'userid': user_id, 'roleid': role_recs[0].id,
|
||||
'id': getID(), 'userid': user_id, 'roleid': role_recs[0].id,
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user