From feaf215b9f36c1c25a7329eed91e1fdcb068a02f Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 17 Nov 2023 14:00:12 +0300 Subject: Bug: Update query in script Update query in script to provide resource_id for the user_roles tabel. --- scripts/register_sys_admin.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'scripts') 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): -- cgit v1.2.3