diff options
Diffstat (limited to 'gn3/auth/authentication')
-rw-r--r-- | gn3/auth/authentication/users.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gn3/auth/authentication/users.py b/gn3/auth/authentication/users.py index ee3b5c2..b2d8d53 100644 --- a/gn3/auth/authentication/users.py +++ b/gn3/auth/authentication/users.py @@ -1,6 +1,6 @@ """User-specific code and data structures.""" from uuid import UUID, uuid4 -from typing import Tuple, NamedTuple +from typing import Any, Tuple, NamedTuple import bcrypt from pymonad.maybe import Just, Maybe, Nothing @@ -17,6 +17,10 @@ class User(NamedTuple): """Return the user's UUID. Mostly for use with Authlib.""" return self.user_id + def dictify(self) -> dict[str, Any]: + """Return a dict representation of `User` objects.""" + return {"user_id": self.user_id, "email": self.email, "name": self.name} + def user_by_email(conn: db.DbConnection, email: str) -> Maybe: """Retrieve user from database by their email address""" with db.cursor(conn) as cursor: |