From 95a751d0060c32d8e1f92308ff739c6177d8319a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Sat, 19 Mar 2022 03:37:24 +0000 Subject: [PATCH] HTTP status out of dep --- api/kiwi_vpn_api/routers/user.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/api/kiwi_vpn_api/routers/user.py b/api/kiwi_vpn_api/routers/user.py index a80e557..3acd3dc 100644 --- a/api/kiwi_vpn_api/routers/user.py +++ b/api/kiwi_vpn_api/routers/user.py @@ -50,13 +50,6 @@ async def dep_get_current_user( username = await config.jwt.decode_token(token) 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 @@ -64,4 +57,11 @@ async def dep_get_current_user( async def 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