From f77ff1ec2298ba4717275ebb9b8f605fbdc1d072 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 17 Jul 2023 17:26:52 +0100 Subject: [PATCH] Put back in validate_token that was foolishly dropped --- backend/app/dependencies.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/app/dependencies.py b/backend/app/dependencies.py index 07fa3c00..45650d1f 100644 --- a/backend/app/dependencies.py +++ b/backend/app/dependencies.py @@ -94,3 +94,12 @@ def validate_jwt_token(token: str = Depends(oauth2_scheme)): except JWTError: logger.error("An error occurred while decoding the JWT token.") raise credentials_exception + + +async def validate_token(token: str = Depends(oauth2_scheme), request: Request = None): + token_data = validate_jwt_token(token) + if not token_data: + raise HTTPException( + status_code=status.HTTP_403_FORBIDDEN, detail="Could not validate credentials" + ) + return token