feat: Updated endpoint endpoints/login.post.py via AI
This commit is contained in:
parent
6d45b355ae
commit
34bd1a6a64
@ -1,13 +1,13 @@
|
|||||||
from fastapi import APIRouter, status, HTTPException
|
from fastapi import APIRouter, HTTPException, status
|
||||||
from schemas.user import UserLogin
|
from schemas.user import UserLogin
|
||||||
from helpers.auth_helpers import login_user
|
from helpers.auth_helpers import authenticate_user
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@router.post("/login", status_code=status.HTTP_200_OK, response_model=UserLogin)
|
@router.post("/login", status_code=status.HTTP_200_OK)
|
||||||
async def login(user_data: UserLogin):
|
async def login(user_data: UserLogin):
|
||||||
"""Authenticate user and retrieve login data"""
|
"""Authenticate user"""
|
||||||
user = login_user(user_data=user_data)
|
user = authenticate_user(user_data)
|
||||||
if not user:
|
if not user:
|
||||||
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid credentials")
|
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid credentials")
|
||||||
return user
|
return user
|
Loading…
x
Reference in New Issue
Block a user