Изменил вебсокет

This commit is contained in:
urec56 2024-06-03 18:20:44 +05:00
parent 8589fec679
commit 7759cdf64d

View file

@ -1,4 +1,6 @@
from fastapi import Depends, WebSocket
from typing import Annotated
from fastapi import Depends, Header
from fastapi.security import HTTPBearer
from jose import JWTError, jwt, ExpiredSignatureError
@ -49,11 +51,10 @@ async def check_verificated_user_with_exc(user: SUser = Depends(get_current_user
return user
def get_token_ws(websocket: WebSocket) -> str:
token = websocket.cookies.get("black_phoenix_access_token")
if not token:
def get_token_ws(authorization: Annotated[str | None, Header()] = None) -> str:
if authorization in None:
raise TokenAbsentException
return token
return authorization.split()[1]
async def get_current_user_ws(token: str = Depends(get_token_ws), uow=Depends(UnitOfWork)):