fix: fix错误

This commit is contained in:
2025-02-26 01:59:46 +08:00
parent 69721f3944
commit 3477d098b7
14 changed files with 71 additions and 75 deletions

View File

@@ -1,8 +1,7 @@
// import './demo/index.ts';
// import { app as adminApp, appendTo } from './admin/index.ts';
import './routes/index.ts';
import { app } from './app.ts';
import { useConfig } from '@kevisual/use-config';
import { User } from './models/user.ts';
import { createAuthRoute } from '@kevisual/auth';
const config = useConfig<{ tokenSecret: string }>();
@@ -16,18 +15,28 @@ app
path: 'auth',
key: 'admin',
id: 'auth-admin',
middleware: ['auth'],
})
.define(async (ctx) => {
// ctx.body = 'admin';
const token = ctx.query?.token;
//
const tokenUser = ctx.state.tokenUser;
const user = await User.findOne({
where: {
id: tokenUser.id,
},
});
if (!user) {
ctx.throw(404, 'user not found');
}
const orgs = await user.getOrgs();
if (orgs.includes('admin')) {
ctx.body = 'admin';
} else {
ctx.throw(403, 'forbidden');
}
})
.addTo(app);
// app.importApp(adminApp);
// appendTo(app);
app
.route({
path: 'test',