feat: Updated endpoint endpoints/login.post.py via AI with auto lint fixes

This commit is contained in:
Backend IM Bot 2025-04-17 14:06:03 +00:00
parent c6125deaf7
commit 6d45b355ae

View File

@ -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))
@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