From 41551584c057306af0d2aa19ee54f850d5cec591 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Sat, 29 Mar 2025 19:34:07 +0000 Subject: [PATCH] Update code in endpoints/login.post.py --- endpoints/login.post.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/endpoints/login.post.py b/endpoints/login.post.py index 12baf4a..d7d7c2e 100644 --- a/endpoints/login.post.py +++ b/endpoints/login.post.py @@ -3,21 +3,22 @@ from sqlalchemy.orm import Session from typing import List from core.database import get_db from models.user import User -from schemas.user import UserSchema, UserCreate, UserLogin -from helpers.user_helpers import authenticate_user +from schemas.user import UserSchema, UserCreate +from helpers.auth_helpers import authenticate_user router = APIRouter() -@router.post("/login", status_code=200, response_model=UserSchema) +@router.post("/login", status_code=200) async def login( - user_data: UserLogin, + username: str, + password: str, db: Session = Depends(get_db) ): - user = authenticate_user(db, user_data.email, user_data.password) + user = authenticate_user(db, username, password) if not user: raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, - detail="Incorrect email or password", + detail="Incorrect username or password", headers={"WWW-Authenticate": "Bearer"}, ) - return user \ No newline at end of file + return {"access_token": "token", "token_type": "bearer"} \ No newline at end of file