mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Account for str valid_tokens_from
This commit is contained in:
parent
251df92528
commit
c3560acbd1
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user