From b6970d21dd0f8e132f8625c09f8aa595350b0218 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Wed, 6 Mar 2024 16:15:05 +0300 Subject: 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 --- gn_auth/auth/authentication/oauth2/endpoints/utilities.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'gn_auth') 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( -- cgit v1.2.3