更新 CNB 配置获取逻辑,修复未授权问题,添加测试文件
This commit is contained in:
@@ -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, '未授权');
|
||||
|
||||
6
agent/routes/cnb-manager/test.ts
Normal file
6
agent/routes/cnb-manager/test.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
const token = 'st_logh1b3ozq2resntxlnk4bccao0bon8e'
|
||||
import { CNBManager } from "../../modules/cnb-manager.ts"
|
||||
const cnbManager = new CNBManager()
|
||||
|
||||
const cnbItem = await cnbManager.getCNB({ username: 'root', kevisualToken: token });
|
||||
console.log('cnbItem', cnbItem)
|
||||
Reference in New Issue
Block a user