Check whether a token has expired

Python · FastAPI · intermediate · greenfield

Adds the expiry check: compares the token's expiry against the current time and returns whether it has passed. Straightforward datetime comparison.

Servers run in various regions; the DB stores expires_at as timezone-aware UTC.

Requirements

Files touched

--- app/auth/expiry.py
+from datetime import datetime
+
+
+def is_expired(token) -> bool:
+    return token.expires_at < datetime.now()

Review this PR

Python practice