From 5d42ffb62b79f7af1609caa75ea6ad885e3e9a78 Mon Sep 17 00:00:00 2001 From: ThearchyHelios Date: Thu, 15 Oct 2026 00:07:51 +0800 Subject: [PATCH] =?UTF-8?q?check-auth=EF=BC=9A=E4=BC=9A=E8=AF=9D=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E6=97=B6=E8=AE=A4=E4=BA=BA=E6=8E=A5=E5=8F=A3=E4=B9=9F?= =?UTF-8?q?=E5=9B=9E=20401=EF=BC=88=E5=90=8C=E6=9C=8D=E5=8A=A1=E7=AB=AF?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E7=84=B6=E7=99=BB=E5=BD=95=E9=A1=B5=E8=AE=A4?= =?UTF-8?q?=E5=BE=97=E5=87=BA=E4=BA=BA=E5=8F=88=E9=80=81=E5=9B=9E=E5=8E=9F?= =?UTF-8?q?=E5=A4=84=E3=80=81=E6=9D=A5=E5=9B=9E=E8=B7=B3=EF=BC=89=EF=BC=9B?= =?UTF-8?q?=E8=BF=87=E6=9C=9F=E5=90=8E=E7=82=B9=E9=A1=B5=E7=AD=BE=E5=8F=AA?= =?UTF-8?q?=E4=B8=BA=E8=A7=A6=E5=8F=91=E5=8F=96=E6=95=B0=EF=BC=8C=E5=A4=96?= =?UTF-8?q?=E5=A3=B3=E5=BF=83=E8=B7=B3=E5=85=88=E6=94=B6=E5=88=B0=20401=20?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E8=B7=B3=E8=B5=B0=E6=97=B6=E7=82=B9=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E4=B8=8D=E7=AE=97=E9=94=99=EF=BC=8C=E6=A0=B8=E5=AF=B9?= =?UTF-8?q?=E7=9A=84=E6=98=AF=E8=B7=B3=E5=88=B0=E4=BA=86=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E5=B9=B6=E5=B8=A6=E4=B8=8A=E5=8E=9F=E5=A4=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/check-auth.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/check-auth.mjs b/scripts/check-auth.mjs index 21bdcf53..3f52393c 100644 --- a/scripts/check-auth.mjs +++ b/scripts/check-auth.mjs @@ -85,7 +85,8 @@ async function open(state) { if (p === '/api/health') return route.continue() if (p === '/api/auth/me') { if (state.mode === 'off') return route.fulfill({ json: { mode: 'off', username: null, display_name: null, role: 'admin', groups: [], verified: false } }) - if (!state.who) return route.fulfill({ status: 401, json: { detail: '请先登录', code: 'auth_required', mode: state.mode } }) + // 会话过期时认人接口也回 401(同服务端):不然登录页认得出人、又把人送回原处,来回跳 + if (!state.who || state.expire) return route.fulfill({ status: 401, json: { detail: '请先登录', code: 'auth_required', mode: state.mode } }) return route.fulfill({ json: { mode: state.mode, ...PEOPLE[state.who], verified: true, user_can_chat: !!state.chat } }) } state.reads?.push(p) @@ -170,7 +171,8 @@ await section('会话中途失效:401 整页跳登录', async () => { await page.goto(`${WEB}/apps?tab=apps`) await nav(page).waitFor({ timeout: 15000 }) state.expire = true - await page.getByRole('tab', { name: '我发起的' }).click() + // 点一下触发一次取数;外壳的心跳可能先收到 401、整页已经跳走了,那时点不到也不要紧——要核对的是跳到了哪里 + await page.getByRole('tab', { name: '我发起的' }).click({ timeout: 3000 }).catch(() => {}) check('任何接口回 401 都跳 /login,带上原处', await page.waitForURL(/\/login\?next=/, { timeout: 15000 }).then(() => true, () => false), page.url()) })