🐛 fix(utils.py): fix TypeError when comparing offset-naive and offset-aware datetimes in get_current_user function

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-30 17:51:57 -03:00
commit 163a7c49cd

View file

@ -89,7 +89,8 @@ async def get_current_user(
user_id: UUID = payload.get("sub") # type: ignore
token_type: str = payload.get("type") # type: ignore
if expires := payload.get("exp", None):
expires_datetime = datetime.fromtimestamp(expires)
expires_datetime = datetime.fromtimestamp(expires, timezone.utc)
# TypeError: can't compare offset-naive and offset-aware datetimes
if datetime.now(timezone.utc) > expires_datetime:
raise credentials_exception