feat: Updated endpoint endpoints/login.post.py via AI with auto lint fixes
This commit is contained in:
parent
c6125deaf7
commit
6d45b355ae
@ -1,16 +1,13 @@
|
|||||||
from fastapi import APIRouter, HTTPException, status
|
from fastapi import APIRouter, status, HTTPException
|
||||||
from typing import Dict, Any
|
from schemas.user import UserLogin
|
||||||
from helpers.generic_helpers import login_user
|
from helpers.auth_helpers import login_user
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@router.post("/login", status_code=status.HTTP_200_OK, response_model=Dict[str, Any])
|
@router.post("/login", status_code=status.HTTP_200_OK, response_model=UserLogin)
|
||||||
async def login(
|
async def login(user_data: UserLogin):
|
||||||
user_data: Dict[str, Any]
|
"""Authenticate user and retrieve login data"""
|
||||||
):
|
user = login_user(user_data=user_data)
|
||||||
"""Login user"""
|
if not user:
|
||||||
try:
|
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid credentials")
|
||||||
login_response = login_user(user_data=user_data)
|
return user
|
||||||
return login_response
|
|
||||||
except ValueError as e:
|
|
||||||
raise HTTPException(status_code=400, detail=str(e))
|
|
Loading…
x
Reference in New Issue
Block a user