|
@@ -0,0 +1,14 @@
|
|
|
+# routes/login.py
|
|
|
+from fastapi import APIRouter, HTTPException
|
|
|
+from common.pojo import BookVo
|
|
|
+from service_demo.impl.AuthServiceImpl import authenticate_user
|
|
|
+
|
|
|
+router = APIRouter()
|
|
|
+
|
|
|
+
|
|
|
+@router.post("/login")
|
|
|
+async def login(user: User):
|
|
|
+ if not authenticate_user(user.username, user.password):
|
|
|
+ raise HTTPException(
|
|
|
+ status_code=401, detail="Incorrect username or password")
|
|
|
+ return {"message": "Login successful", "username": user.username}
|