feat: 登录机制改为账号+密码模式,默认账号root

This commit is contained in:
2026-04-22 15:58:59 +08:00
parent 51084de7e1
commit fa657940af
3 changed files with 13 additions and 6 deletions
+4 -4
View File
@@ -110,10 +110,10 @@ async def jwt_middleware(request: Request, call_next):
@app.post("/api/login")
async def login(password: str = Body(..., embed=True)):
if password != ADMIN_PASSWORD:
return JSONResponse(status_code=401, content={"detail": "密码错误"})
token = create_jwt_token({"user": "admin"})
async def login(username: str = Body(..., embed=True), password: str = Body(..., embed=True)):
if username != "root" or password != ADMIN_PASSWORD:
return JSONResponse(status_code=401, content={"detail": "账号或密码错误"})
token = create_jwt_token({"user": username})
return {"success": True, "token": token}