diff options
Diffstat (limited to 'gn3/auth/authorisation/privileges.py')
-rw-r--r-- | gn3/auth/authorisation/privileges.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gn3/auth/authorisation/privileges.py b/gn3/auth/authorisation/privileges.py index 9e66bda..6cfd1d8 100644 --- a/gn3/auth/authorisation/privileges.py +++ b/gn3/auth/authorisation/privileges.py @@ -1,5 +1,4 @@ """Handle privileges""" -from uuid import UUID from typing import Iterable, NamedTuple from gn3.auth import db @@ -7,14 +6,14 @@ from gn3.auth.authentication.users import User class Privilege(NamedTuple): """Class representing a privilege: creates immutable objects.""" - privilege_id: UUID - privilege_name: str + privilege_id: str + privilege_description: str def user_privileges(conn: db.DbConnection, user: User) -> Iterable[Privilege]: """Fetch the user's privileges from the database.""" with db.cursor(conn) as cursor: cursor.execute( - ("SELECT p.privilege_id, p.privilege_name " + ("SELECT p.privilege_id, p.privilege_description " "FROM user_roles AS ur " "INNER JOIN role_privileges AS rp ON ur.role_id=rp.role_id " "INNER JOIN privileges AS p ON rp.privilege_id=p.privilege_id " @@ -22,4 +21,4 @@ def user_privileges(conn: db.DbConnection, user: User) -> Iterable[Privilege]: (str(user.user_id),)) results = cursor.fetchall() - return (Privilege(UUID(row[0]), row[1]) for row in results) + return (Privilege(row[0], row[1]) for row in results) |