13 lines
502 B
Python
13 lines
502 B
Python
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=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 |