aboutsummaryrefslogtreecommitdiff
path: root/scripts/register_sys_admin.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/register_sys_admin.py')
-rw-r--r--scripts/register_sys_admin.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/scripts/register_sys_admin.py b/scripts/register_sys_admin.py
index 7d4d667..78a0b33 100644
--- a/scripts/register_sys_admin.py
+++ b/scripts/register_sys_admin.py
@@ -61,8 +61,19 @@ def save_admin(conn: db.DbConnection, name: str, email: str, passwd: str):
cursor.execute(
"SELECT * FROM roles WHERE role_name='system-administrator'")
admin_role = cursor.fetchone()
- cursor.execute("INSERT INTO user_roles VALUES (:user_id, :role_id)",
- {**admin, "role_id": admin_role["role_id"]})
+ cursor.execute(
+ "SELECT * FROM resources AS r "
+ "INNER JOIN resource_categories AS rc "
+ "ON r.resource_category_id=rc.resource_category_id "
+ "WHERE resource_category_key='system'")
+ the_system = cursor.fetchall()
+ cursor.execute(
+ "INSERT INTO user_roles VALUES (:user_id, :role_id, :resource_id)",
+ {
+ **admin,
+ "role_id": admin_role["role_id"],
+ "resource_id": the_system["resource_id"]
+ })
return 0
def register_admin(authdbpath: Path):