From 7c0ee01c1d134cbee0a2c8243dd55e4eeaaa5f7c Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 30 May 2024 12:03:38 -0500 Subject: Move user creation from db resultset into static method Creation of a User object from the database resultset will mostly be the same. This commit moves the repetitive code into a static method that can be called wherever we need it. This improves maintainability, since we only ever need to do an update in one place now. --- gn_auth/auth/authentication/oauth2/grants/authorisation_code_grant.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gn_auth/auth/authentication/oauth2') diff --git a/gn_auth/auth/authentication/oauth2/grants/authorisation_code_grant.py b/gn_auth/auth/authentication/oauth2/grants/authorisation_code_grant.py index a40292e..c285c96 100644 --- a/gn_auth/auth/authentication/oauth2/grants/authorisation_code_grant.py +++ b/gn_auth/auth/authentication/oauth2/grants/authorisation_code_grant.py @@ -81,8 +81,7 @@ class AuthorisationCodeGrant(grants.AuthorizationCodeGrant): cursor.execute(query, (str(authorization_code.code),)) res = cursor.fetchone() if res: - return User( - uuid.UUID(res["user_id"]), res["email"], res["name"]) + return User.from_sqlite3_row(res) return None -- cgit v1.2.3