fix: change to release script to config directory

This commit is contained in:
2025-02-27 00:00:38 +08:00
parent 3477d098b7
commit 2b90bbab6f
8 changed files with 57 additions and 36 deletions

View File

@@ -15,24 +15,35 @@ app
path: 'auth',
key: 'admin',
id: 'auth-admin',
isDebug: true,
middleware: ['auth'],
})
.define(async (ctx) => {
const tokenUser = ctx.state.tokenUser;
const user = await User.findOne({
where: {
id: tokenUser.id,
},
});
if (!user) {
ctx.throw(404, 'user not found');
if (!tokenUser) {
ctx.throw(401, 'No User For authorized');
}
const orgs = await user.getOrgs();
try {
const user = await User.findOne({
where: {
id: tokenUser.id,
},
});
if (!user) {
ctx.throw(404, 'user not found');
}
user.setTokenUser(tokenUser);
const orgs = await user.getOrgs();
if (orgs.includes('admin')) {
ctx.body = 'admin';
} else {
ctx.throw(403, 'forbidden');
if (orgs.includes('admin')) {
ctx.body = 'admin';
ctx.nextQuery = ctx.query;
} else {
ctx.throw(403, 'forbidden');
}
} catch (e) {
console.error('auth-admin error', e);
ctx.throw(500, e.message);
}
})
.addTo(app);