diff options
author | Frederick Muriuki Muriithi | 2025-07-30 09:27:32 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-07-30 09:49:04 -0500 |
commit | cb8fe53f54e5e2065c6a4829aecce1db093d9034 (patch) | |
tree | db39b081d35cfa4de335180de1a7b906098dbbc6 | |
parent | fcd6551c4f82248b71d9241085773e24adcf24e9 (diff) | |
download | gn-auth-cb8fe53f54e5e2065c6a4829aecce1db093d9034.tar.gz |
Rename function, retaining some backwards compatibility.
-rw-r--r-- | gn_auth/auth/authorisation/users/admin/models.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gn_auth/auth/authorisation/users/admin/models.py b/gn_auth/auth/authorisation/users/admin/models.py index 53f1f68..21e4a58 100644 --- a/gn_auth/auth/authorisation/users/admin/models.py +++ b/gn_auth/auth/authorisation/users/admin/models.py @@ -1,10 +1,10 @@ """Major function for handling admin users.""" +import warnings + from gn_auth.auth.db import sqlite3 as db from gn_auth.auth.authentication.users import User from gn_auth.auth.authorisation.roles.models import Role, db_rows_to_roles -def make_sys_admin(cursor: db.DbCursor, user: User) -> User: - """Make a given user into an system admin.""" def sysadmin_role(conn: db.DbConnection) -> Role: """Fetch the `system-administrator` role details.""" @@ -23,6 +23,8 @@ def sysadmin_role(conn: db.DbConnection) -> Role: return results[0] +def grant_sysadmin_role(cursor: db.DbCursor, user: User) -> User: + """Grant `system-administrator` role to `user`.""" cursor.execute( "SELECT * FROM roles WHERE role_name='system-administrator'") admin_role = cursor.fetchone() @@ -40,3 +42,12 @@ def sysadmin_role(conn: db.DbConnection) -> Role: "resource_id": the_system["resource_id"] }) return user + + +def make_sys_admin(cursor: db.DbCursor, user: User) -> User: + """Make a given user into an system admin.""" + warnings.warn( + DeprecationWarning( + f"The function `{__name__}.make_sys_admin` will be removed soon"), + stacklevel=1) + return grant_sysadmin_role(cursor, user) |