HTTP status out of dep

This commit is contained in:
Jörn-Michael Miehe 2022-03-19 03:37:24 +00:00
parent 900131fae8
commit 95a751d006

View file

@ -50,13 +50,6 @@ async def dep_get_current_user(
username = await config.jwt.decode_token(token) username = await config.jwt.decode_token(token)
user = schemas.User.from_db(db, username) user = schemas.User.from_db(db, username)
if user is None:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Could not validate credentials",
headers={"WWW-Authenticate": "Bearer"},
)
return user return user
@ -64,4 +57,11 @@ async def dep_get_current_user(
async def get_current_user( async def get_current_user(
current_user: schemas.User = Depends(dep_get_current_user), current_user: schemas.User = Depends(dep_get_current_user),
): ):
if current_user is None:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Could not validate credentials",
headers={"WWW-Authenticate": "Bearer"},
)
return current_user return current_user