From fa657940aff4474dc895de850789bf706d7edbbe Mon Sep 17 00:00:00 2001 From: Nixevol Date: Wed, 22 Apr 2026 15:58:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=99=BB=E5=BD=95=E6=9C=BA=E5=88=B6?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E8=B4=A6=E5=8F=B7+=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=EF=BC=8C=E9=BB=98=E8=AE=A4=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?root?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.py | 8 ++++---- static/index.html | 7 ++++++- static/js/app.js | 4 +++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index c956bcb..6a2b31b 100644 --- a/app/main.py +++ b/app/main.py @@ -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} diff --git a/static/index.html b/static/index.html index e75a667..e28c4ac 100644 --- a/static/index.html +++ b/static/index.html @@ -495,8 +495,13 @@