From 1becce7092e5e2af4c0b80a96be43d35c8b8002e Mon Sep 17 00:00:00 2001 From: anghunk Date: Fri, 6 Feb 2026 16:51:50 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=20API=20=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E5=92=8C=E7=99=BB=E5=BD=95=E6=8E=A5=E5=8F=A3=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cwd-api/src/api/admin/login.ts | 6 +++--- docs/api/admin/auth.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cwd-api/src/api/admin/login.ts b/cwd-api/src/api/admin/login.ts index 351c929..f7ebf60 100644 --- a/cwd-api/src/api/admin/login.ts +++ b/cwd-api/src/api/admin/login.ts @@ -15,7 +15,7 @@ export const adminLogin = async (c: Context<{ Bindings: Bindings }>) => { // 1. 检查 IP 是否被封禁 const isBlocked = await c.env.CWD_AUTH_KV.get(blockKey); if (isBlocked) { - return c.json({ message: 'IP is blocked due to multiple failed login attempts' }, 403); + return c.json({ message: 'IP 已被封禁,30 分钟后重试' }, 403); } // 2. 验证用户名密码 @@ -32,11 +32,11 @@ export const adminLogin = async (c: Context<{ Bindings: Bindings }>) => { // 达到上限,封禁 30 分钟 await c.env.CWD_AUTH_KV.put(blockKey, '1', { expirationTtl: LOCK_TIME }); await c.env.CWD_AUTH_KV.delete(attemptKey); // 清除尝试计数 - return c.json({ message: 'IP is blocked due to multiple failed login attempts' }, 403); + return c.json({ message: 'IP 已被封禁,30 分钟后重试' }, 403); } else { // 记录失败次数,设置 10 分钟内连续失败才计数 await c.env.CWD_AUTH_KV.put(attemptKey, attempts.toString(), { expirationTtl: 600 }); - return c.json({ message: 'Invalid username or password', failedAttempts: attempts }, 401); + return c.json({ message: '用户名或密码无效', failedAttempts: attempts }, 401); } } diff --git a/docs/api/admin/auth.md b/docs/api/admin/auth.md index 74a2b28..f58c150 100644 --- a/docs/api/admin/auth.md +++ b/docs/api/admin/auth.md @@ -85,7 +85,7 @@ POST /admin/login ```json { - "message": "Invalid username or password", + "message": "用户名或密码无效", "failedAttempts": 3 } ``` @@ -97,7 +97,7 @@ POST /admin/login ```json { - "message": "IP is blocked due to multiple failed login attempts" + "message": "IP 已被封禁,30 分钟后重试" } ```