diff options
author | Frederick Muriuki Muriithi | 2023-11-17 14:00:12 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-11-17 14:00:12 +0300 |
commit | feaf215b9f36c1c25a7329eed91e1fdcb068a02f (patch) | |
tree | e23620db01442df9ce1a02c1d9398434e07725c2 | |
parent | 8c6fffb7914d32df513939f05e6258dd4e6a81ad (diff) | |
download | gn-auth-feaf215b9f36c1c25a7329eed91e1fdcb068a02f.tar.gz |
Bug: Update query in script
Update query in script to provide resource_id for the user_roles tabel.
-rw-r--r-- | scripts/register_sys_admin.py | 15 |
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): |