aboutsummaryrefslogtreecommitdiff
path: root/gn3/auth/authentication/users.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-06-30 09:19:39 +0300
committerFrederick Muriuki Muriithi2023-06-30 09:19:39 +0300
commitcd16f99aa23123f2398e3a3a542d84363d7a7b16 (patch)
tree019eadec715989ee80cc62f5f78070d54dc8c75d /gn3/auth/authentication/users.py
parentd46d1eb47f9ee18518894d850a18cd952231dddc (diff)
downloadgenenetwork3-cd16f99aa23123f2398e3a3a542d84363d7a7b16.tar.gz
List all OAuth2 clients.
Diffstat (limited to 'gn3/auth/authentication/users.py')
-rw-r--r--gn3/auth/authentication/users.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/gn3/auth/authentication/users.py b/gn3/auth/authentication/users.py
index 8b4f115..0e72ed2 100644
--- a/gn3/auth/authentication/users.py
+++ b/gn3/auth/authentication/users.py
@@ -110,3 +110,19 @@ def set_user_password(
"ON CONFLICT (user_id) DO UPDATE SET password=:hash"),
{"user_id": str(user.user_id), "hash": hashed_password})
return user, hashed_password
+
+def users(conn: db.DbConnection,
+ ids: tuple[UUID, ...] = tuple()) -> tuple[User, ...]:
+ """
+ Fetch all users with the given `ids`. If `ids` is empty, return ALL users.
+ """
+ params = ", ".join(["?"] * len(ids))
+ with db.cursor(conn) as cursor:
+ query = "SELECT * FROM users" + (
+ f" WHERE user_id IN ({params})"
+ if len(ids) > 0 else "")
+ print(query)
+ cursor.execute(query, tuple(str(the_id) for the_id in ids))
+ return tuple(User(UUID(row["user_id"]), row["email"], row["name"])
+ for row in cursor.fetchall())
+ return tuple()