From 05b60b2dc6bd2187501b2583cdaa27a90c45b1d5 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Mon, 21 Nov 2022 14:06:23 -0600 Subject: graphql: T4574: add specific error message if token has expired Catch expiration error and return error-specific message instead of general 'not authenticated'. --- src/services/api/graphql/libs/token_auth.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/services/api/graphql/libs/token_auth.py') diff --git a/src/services/api/graphql/libs/token_auth.py b/src/services/api/graphql/libs/token_auth.py index 3ecd8b855..2100eba7f 100644 --- a/src/services/api/graphql/libs/token_auth.py +++ b/src/services/api/graphql/libs/token_auth.py @@ -54,6 +54,9 @@ def get_user_context(request): user_id: str = payload.get('sub') if user_id is None: return context + except jwt.exceptions.ExpiredSignatureError: + context['error'] = 'expired token' + return context except jwt.PyJWTError: return context try: -- cgit v1.2.3