🐛 fix(utils.py): fix TypeError when comparing offset-naive and offset-aware datetimes in get_current_user function
This commit is contained in:
parent
61f0a93cc6
commit
163a7c49cd
1 changed files with 2 additions and 1 deletions
|
|
@ -89,7 +89,8 @@ async def get_current_user(
|
||||||
user_id: UUID = payload.get("sub") # type: ignore
|
user_id: UUID = payload.get("sub") # type: ignore
|
||||||
token_type: str = payload.get("type") # type: ignore
|
token_type: str = payload.get("type") # type: ignore
|
||||||
if expires := payload.get("exp", None):
|
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:
|
if datetime.now(timezone.utc) > expires_datetime:
|
||||||
raise credentials_exception
|
raise credentials_exception
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue