aboutsummaryrefslogtreecommitdiff
path: root/gn_auth/auth/authentication/oauth2/endpoints
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-03-06 16:15:05 +0300
committerMunyoki Kilyungi2024-03-08 15:03:53 +0300
commitb6970d21dd0f8e132f8625c09f8aa595350b0218 (patch)
tree51918e1ae3dff7c0c5b415d04510e6478b87f815 /gn_auth/auth/authentication/oauth2/endpoints
parent82f76b879be1baafeddc80bc361744e59e47e42b (diff)
downloadgn-auth-b6970d21dd0f8e132f8625c09f8aa595350b0218.tar.gz
Correctly check for the refresh_token.
* gn_auth/auth/authentication/oauth2/endpoints/utilities.py (query_token): Replace "if" with "match" syntax. Also, correctly check for the "refresh_token". Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn_auth/auth/authentication/oauth2/endpoints')
-rw-r--r--gn_auth/auth/authentication/oauth2/endpoints/utilities.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/gn_auth/auth/authentication/oauth2/endpoints/utilities.py b/gn_auth/auth/authentication/oauth2/endpoints/utilities.py
index 2c13c66..08b2a3b 100644
--- a/gn_auth/auth/authentication/oauth2/endpoints/utilities.py
+++ b/gn_auth/auth/authentication/oauth2/endpoints/utilities.py
@@ -17,10 +17,17 @@ def query_token(# pylint: disable=[unused-argument]
return val
token = Nothing
with db.connection(current_app.config["AUTH_DB"]) as conn:
- if token_type_hint == "access_token":
- token = token_by_access_token(conn, token_str)
- if token_type_hint == "access_token":
- token = token_by_refresh_token(conn, token_str)
+ match token_type_hint:
+ case "access_token":
+ token = token_by_access_token(
+ conn, token_str
+ )
+ case "refresh_token":
+ token = token_by_refresh_token(
+ conn, token_str
+ )
+ case _:
+ token = Nothing
return token.maybe(
token_by_access_token(conn, token_str).maybe(