diff options
author | Frederick Muriuki Muriithi | 2023-03-23 09:18:10 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-03-23 09:18:10 +0300 |
commit | d4b48aef6cca3182559f7479cace3bd77cc1fb40 (patch) | |
tree | 358b8ebd611f9e59f00f8d10b7705bc51947dc29 /gn3/auth/authentication/oauth2 | |
parent | de20ab3834f2a84fd3f2ba9657650e28898e27f0 (diff) | |
download | genenetwork3-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.
Diffstat (limited to 'gn3/auth/authentication/oauth2')
-rw-r--r-- | gn3/auth/authentication/oauth2/models/oauth2client.py | 11 |
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"], |