05/02/2026 updated code for security 2

This commit is contained in:
2026-05-02 18:44:39 -04:00
parent c7b1806ec8
commit 78feedc5c7
15 changed files with 1347 additions and 182 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone
from sqlalchemy.dialects.mysql import INTEGER
@@ -20,10 +20,10 @@ class TokenBlacklist(db.Model):
if not entry:
return False
# Automatically ignore expired entries (they can be cleaned up later)
return entry.expires_at > datetime.utcnow()
return entry.expires_at > datetime.now(timezone.utc).replace(tzinfo=None)
@classmethod
def cleanup_expired(cls):
"""Delete entries that have already expired — call occasionally to keep table small."""
cls.query.filter(cls.expires_at <= datetime.utcnow()).delete()
cls.query.filter(cls.expires_at <= datetime.now(timezone.utc).replace(tzinfo=None)).delete()
db.session.commit()