Добавлена response_model=User в get_current_user

This commit is contained in:
DmitryGantimurov 2023-07-19 00:14:56 +03:00
parent d5ba710885
commit 30140f058f

View File

@ -69,14 +69,14 @@ def create_access_token(data: dict, expires_delta: Union[timedelta, None] = None
return encoded_jwt
async def get_current_user(db: SessionLocal, token: Annotated[str, Depends(oauth2_scheme)]):
async def get_current_user(db: SessionLocal, token: Annotated[str, Depends(oauth2_scheme)], response_model=User):
credentials_exception = HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Could not validate credentials",
headers={"WWW-Authenticate": "Bearer"},
)
try:
payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM], response_model=User)
payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])
email: str = payload.get("sub")
if email is None:
raise credentials_exception