aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-03-23 09:18:10 +0300
committerFrederick Muriuki Muriithi2023-03-23 09:18:10 +0300
commitd4b48aef6cca3182559f7479cace3bd77cc1fb40 (patch)
tree358b8ebd611f9e59f00f8d10b7705bc51947dc29
parentde20ab3834f2a84fd3f2ba9657650e28898e27f0 (diff)
downloadgenenetwork3-d4b48aef6cca3182559f7479cace3bd77cc1fb40.tar.gz
auth: Don't try loading the user if no client is found
Fix the bug where the system was trying to load a user from a non-existing OAuth2 client, leading to an exception.
-rw-r--r--gn3/auth/authentication/oauth2/models/oauth2client.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/gn3/auth/authentication/oauth2/models/oauth2client.py b/gn3/auth/authentication/oauth2/models/oauth2client.py
index 5054393..da5ff75 100644
--- a/gn3/auth/authentication/oauth2/models/oauth2client.py
+++ b/gn3/auth/authentication/oauth2/models/oauth2client.py
@@ -137,12 +137,13 @@ def client(conn: db.DbConnection, client_id: uuid.UUID,
"SELECT * FROM oauth2_clients WHERE client_id=?", (str(client_id),))
result = cursor.fetchone()
the_user = user
- if not bool(the_user):
- try:
- the_user = user_by_id(conn, result["user_id"])
- except NotFoundError as _nfe:
- the_user = None
if result:
+ if not bool(the_user):
+ try:
+ the_user = user_by_id(conn, result["user_id"])
+ except NotFoundError as _nfe:
+ the_user = None
+
return Just(
OAuth2Client(uuid.UUID(result["client_id"]),
result["client_secret"],