diff options
Diffstat (limited to 'gn_auth/auth/authorisation/privileges.py')
-rw-r--r-- | gn_auth/auth/authorisation/privileges.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gn_auth/auth/authorisation/privileges.py b/gn_auth/auth/authorisation/privileges.py index fabab65..a977db5 100644 --- a/gn_auth/auth/authorisation/privileges.py +++ b/gn_auth/auth/authorisation/privileges.py @@ -2,6 +2,8 @@ from dataclasses import dataclass from typing import Iterable +import sqlite3 + from ..db import sqlite3 as db from ..authentication.users import User @@ -13,6 +15,12 @@ class Privilege: privilege_description: str +def db_row_to_privilege(row: sqlite3.Row) -> Privilege: + "Convert single db row into a privilege object." + return Privilege(privilege_id=row["privilege_id"], + privilege_description=row["privilege_description"]) + + def user_privileges(conn: db.DbConnection, user: User) -> Iterable[Privilege]: """Fetch the user's privileges from the database.""" with db.cursor(conn) as cursor: |