优化登录身份缓存机制

This commit is contained in:
eoao
2025-07-04 20:02:00 +08:00
parent 1f7b9381e6
commit 4367cf948d
4 changed files with 6 additions and 5 deletions
-4
View File
@@ -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);
});