优化 auth 中间件的日志输出;注释掉未使用的路由定义;更新 page-proxy-app 路由的描述和中间件

This commit is contained in:
2026-01-26 20:53:51 +08:00
parent c4e5668b29
commit c3624a59de
2 changed files with 29 additions and 23 deletions

View File

@@ -29,12 +29,11 @@ export const addAuth = (app: App) => {
ctx.throw(401, 'Token is required');
}
const user = await User.getOauthUser(token);
console.log('auth user: exists', !user);
if (!user) {
ctx.throw(401, 'Token is invalid');
return;
}
console.log(`auth user: ${user.username} (${user.id})`);
// console.log(`auth user: ${user.username} (${user.id})`);
const someInfo = getSomeInfoFromReq(ctx);
if (someInfo.isBrowser && !ctx.req?.cookies?.['token']) {
createCookie({ accessToken: token }, ctx);
@@ -87,6 +86,7 @@ app
if (!tokenUser) {
ctx.throw(401, 'No User For authorized');
}
console.log('auth-admin tokenUser', ctx.state);
if (typeof ctx.state.isAdmin !== 'undefined' && ctx.state.isAdmin === true) {
return;
}
@@ -114,6 +114,7 @@ app
}
})
.addTo(app);
app
.route({
path: 'auth-check',