feat: 注释掉auth中间件中对checkAppId的调用,避免重复验证用户信息

This commit is contained in:
2026-03-10 00:13:00 +08:00
parent efb30708eb
commit 38d31a9fb5

View File

@@ -40,12 +40,12 @@ export const addAuth = (app: App) => {
})
.define(async (ctx) => {
const token = ctx.query.token;
if (checkAppId(ctx, app.appId)) {
ctx.state.tokenUser = {
username: 'default',
}
return;
}
// if (checkAppId(ctx, app.appId)) {
// ctx.state.tokenUser = {
// username: 'default',
// }
// return;
// }
// 已经有用户信息则直接返回,不需要重复验证
if (ctx.state.tokenUser) {
return;
@@ -75,12 +75,12 @@ export const addAuth = (app: App) => {
description: '验证token可以不成功错误不返回401正确赋值到ctx.state.tokenUser失败赋值null',
})
.define(async (ctx) => {
if (checkAppId(ctx, app.appId)) {
ctx.state.tokenUser = {
username: 'default',
}
return;
}
// if (checkAppId(ctx, app.appId)) {
// ctx.state.tokenUser = {
// username: 'default',
// }
// return;
// }
// 已经有用户信息则直接返回,不需要重复验证
if (ctx.state.tokenUser) {
return;
@@ -113,12 +113,12 @@ app
description: '验证token必须是admin用户, 错误返回403正确赋值到ctx.state.tokenAdmin',
})
.define(async (ctx) => {
if (checkAppId(ctx, app.appId)) {
ctx.state.tokenUser = {
username: 'default',
}
return;
}
// if (checkAppId(ctx, app.appId)) {
// ctx.state.tokenUser = {
// username: 'default',
// }
// return;
// }
const tokenUser = ctx.state.tokenUser;
if (!tokenUser) {
ctx.throw(401, 'No User For authorized');