Update app.py
Browse files
app.py
CHANGED
|
@@ -23,9 +23,18 @@ def validate_token(token):
|
|
| 23 |
users = get_users_from_db()
|
| 24 |
for user in users:
|
| 25 |
if user["token"] == token:
|
|
|
|
| 26 |
expiration_time = datetime.fromisoformat(user["token_expiration_time"])
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
else:
|
| 30 |
return False, "Token has expired."
|
| 31 |
return False, "Token not found."
|
|
|
|
| 23 |
users = get_users_from_db()
|
| 24 |
for user in users:
|
| 25 |
if user["token"] == token:
|
| 26 |
+
# Parse the expiration time from the database
|
| 27 |
expiration_time = datetime.fromisoformat(user["token_expiration_time"])
|
| 28 |
+
|
| 29 |
+
# Get the current time in the same format
|
| 30 |
+
current_time = datetime.now()
|
| 31 |
+
|
| 32 |
+
print(f"Token Expiration Time: {expiration_time}")
|
| 33 |
+
print(f"Current Time: {current_time}")
|
| 34 |
+
|
| 35 |
+
# Check if the token has expired
|
| 36 |
+
if current_time < expiration_time:
|
| 37 |
+
return True, None # Token is valid
|
| 38 |
else:
|
| 39 |
return False, "Token has expired."
|
| 40 |
return False, "Token not found."
|