From c3560acbd10a9086b64ad92a10ce531f8fc36c21 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Fri, 31 May 2024 12:45:29 -0400 Subject: [PATCH] Account for str valid_tokens_from --- app/classes/shared/authentication.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/classes/shared/authentication.py b/app/classes/shared/authentication.py index 041f3f80..94db5532 100644 --- a/app/classes/shared/authentication.py +++ b/app/classes/shared/authentication.py @@ -63,13 +63,16 @@ class Authentication: user = HelperUsers.get_user(user_id) # TODO: Have a cache or something so we don't constantly # have to query the database - valid_tokens_from_str = user.get("valid_tokens_from") - + # It's possible this will be a string or a dt coming from the DB + # We need to account for that + try: + valid_tokens_from_dt = datetime.strptime( + valid_tokens_from_str, "%Y-%m-%d %H:%M:%S.%f%z" + ) + except TypeError: + valid_tokens_from_dt = valid_tokens_from_str # Convert the string to a datetime object - valid_tokens_from_dt = datetime.strptime( - valid_tokens_from_str, "%Y-%m-%d %H:%M:%S.%f%z" - ) if int(valid_tokens_from_dt.timestamp()) < iat: # Success! return key, data, user