HTTP status out of dep
This commit is contained in:
parent
900131fae8
commit
95a751d006
1 changed files with 7 additions and 7 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue