From 6d45b355ae395602de9072b9c932b277dee36630 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Thu, 17 Apr 2025 14:06:03 +0000 Subject: [PATCH] feat: Updated endpoint endpoints/login.post.py via AI with auto lint fixes --- endpoints/login.post.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/endpoints/login.post.py b/endpoints/login.post.py index c56b149..14a3261 100644 --- a/endpoints/login.post.py +++ b/endpoints/login.post.py @@ -1,16 +1,13 @@ -from fastapi import APIRouter, HTTPException, status -from typing import Dict, Any -from helpers.generic_helpers import login_user +from fastapi import APIRouter, status, HTTPException +from schemas.user import UserLogin +from helpers.auth_helpers import login_user router = APIRouter() -@router.post("/login", status_code=status.HTTP_200_OK, response_model=Dict[str, Any]) -async def login( - user_data: Dict[str, Any] -): - """Login user""" - try: - login_response = login_user(user_data=user_data) - return login_response - except ValueError as e: - raise HTTPException(status_code=400, detail=str(e)) \ No newline at end of file +@router.post("/login", status_code=status.HTTP_200_OK, response_model=UserLogin) +async def login(user_data: UserLogin): + """Authenticate user and retrieve login data""" + user = login_user(user_data=user_data) + if not user: + raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid credentials") + return user \ No newline at end of file