change status error code when login fails from 400 (bad request) to 401 (unauthorized)

parent 412c8455
Showing with 1 additions and 1 deletions
...@@ -78,7 +78,7 @@ def authenticate_user(db: Session, email: str, password: str): ...@@ -78,7 +78,7 @@ def authenticate_user(db: Session, email: str, password: str):
def login_user(db, email: str, password: str): def login_user(db, email: str, password: str):
user = authenticate_user(db, email, password) user = authenticate_user(db, email, password)
if not user: if not user:
raise HTTPException(status_code=400, detail="Incorrect username or password") raise HTTPException(status_code=401, detail="Incorrect username or password")
access_token_expires = timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES) access_token_expires = timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
access_token = create_access_token( access_token = create_access_token(
data={"sub": user.email, "role": user.role, "id": user.id}, data={"sub": user.email, "role": user.role, "id": user.id},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment