health-apps-backend/apis/endpoints/auth.py

23 lines
604 B
Python

from fastapi import APIRouter
from services.authService import AuthService
from schemas.CreateSchemas import UserCreate
from schemas.ApiResponse import ApiResponse
router = APIRouter()
@router.post("/login")
async def login(email: str, password: str):
token = await AuthService().login(email, password)
return ApiResponse(
data=token,
message="Login successful"
)
@router.post("/register")
async def register(user_data: UserCreate):
await AuthService().register(user_data)
return ApiResponse(
data="OK",
message="User registered successfully"
)