🐛 fix(chat.py): close websocket connection with status code 1008 and reason "Unauthorized" if user is not authenticated or inactive
🐛 fix(auth/utils.py): raise credentials_exception if token has expired
This commit is contained in:
parent
53b9565ac6
commit
eacf558e70
2 changed files with 18 additions and 3 deletions
|
|
@ -88,6 +88,10 @@ 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)
|
||||
if datetime.now(timezone.utc) > expires_datetime:
|
||||
raise credentials_exception
|
||||
|
||||
if user_id is None or token_type:
|
||||
raise credentials_exception
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue