更新 CNB 配置获取逻辑,修复未授权问题,添加测试文件

This commit is contained in:
xiongxiao
2026-03-13 04:33:16 +08:00
committed by cnb
parent cda1d0dc8f
commit d9fda44e78
4 changed files with 15 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ app.route({
middleware: ['auth'],
}).define(async (ctx) => {
const tokenUser = ctx.tokenUser;
const tokenUser = ctx.state?.tokenUser;
if (!tokenUser) {
ctx.throw(401, '未授权');
}
@@ -29,7 +29,8 @@ app.route({
description: '获取我的cnb配置',
middleware: ['auth'],
}).define(async (ctx) => {
const username = ctx.tokenUser?.username;
const tokenUser = ctx.state?.tokenUser;
const username = tokenUser?.username;
const token = ctx.query?.token;
if (!username) {
ctx.throw(400, '未授权');