From 4367cf948dfea2547235c81d46df5fdce43abd4f Mon Sep 17 00:00:00 2001 From: eoao Date: Fri, 4 Jul 2025 20:02:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=99=BB=E5=BD=95=E8=BA=AB?= =?UTF-8?q?=E4=BB=BD=E7=BC=93=E5=AD=98=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mail-vue/src/layout/header/index.vue | 2 +- mail-worker/src/security/security.js | 4 ---- mail-worker/src/service/login-service.js | 4 ++++ mail-worker/src/utils/jwt-utils.js | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mail-vue/src/layout/header/index.vue b/mail-vue/src/layout/header/index.vue index 66af99c..ea8e881 100644 --- a/mail-vue/src/layout/header/index.vue +++ b/mail-vue/src/layout/header/index.vue @@ -131,7 +131,7 @@ function clickLogout() { logoutLoading.value = true logout().then(() => { localStorage.removeItem("token") - router.push('/login') + router.replace('/login') }).finally(() => { logoutLoading.value = false }) diff --git a/mail-worker/src/security/security.js b/mail-worker/src/security/security.js index bec5e50..27de3a8 100644 --- a/mail-worker/src/security/security.js +++ b/mail-worker/src/security/security.js @@ -92,7 +92,6 @@ app.use('*', async (c, next) => { const result = await jwtUtils.verifyToken(c, jwt); if (!result) { - console.error(401,1) throw new BizError('身份认证失效,请重新登录', 401); } @@ -100,16 +99,13 @@ app.use('*', async (c, next) => { const authInfo = await c.env.kv.get(KvConst.AUTH_INFO + userId, { type: 'json' }); if (!authInfo) { - console.error(401,2) throw new BizError('身份认证失效,请重新登录', 401); } if (!authInfo.tokens.includes(token)) { - console.error(401,3) throw new BizError('身份认证失效,请重新登录', 401); } - const permIndex = requirePerms.findIndex(item => { return path.startsWith(item); }); diff --git a/mail-worker/src/service/login-service.js b/mail-worker/src/service/login-service.js index f905d3f..99de6fc 100644 --- a/mail-worker/src/service/login-service.js +++ b/mail-worker/src/service/login-service.js @@ -96,6 +96,10 @@ const loginService = { if (authInfo) { + if (authInfo.tokens.length > 10) { + authInfo.tokens.shift(); + } + authInfo.tokens.push(uuid); } else { diff --git a/mail-worker/src/utils/jwt-utils.js b/mail-worker/src/utils/jwt-utils.js index cae2ebc..424fb2b 100644 --- a/mail-worker/src/utils/jwt-utils.js +++ b/mail-worker/src/utils/jwt-utils.js @@ -79,6 +79,7 @@ const jwtUtils = { return payload; } catch (err) { + console.log(err) return null; } }