feat: add minio list detect

This commit is contained in:
2025-03-13 02:32:28 +08:00
parent 1c820c3083
commit efef48a1b0
8 changed files with 208 additions and 15 deletions

View File

@@ -64,6 +64,7 @@ app
if (!user) {
ctx.throw('user not found');
}
user.setTokenUser(tokenUser);
const orgs = await user.getOrgs();
if (!orgs.includes('admin')) {
ctx.throw('Permission denied');
@@ -136,3 +137,38 @@ app
};
})
.addTo(app);
app
.route({
path: 'org',
key: 'hasUser',
middleware: ['auth'],
})
.define(async (ctx) => {
const tokenUser = ctx.state.tokenUser;
const { username } = ctx.query.data;
const user = await User.findByPk(tokenUser.id);
if (!user) {
ctx.throw('user not found');
}
user.setTokenUser(tokenUser);
const userOrgs = await user.hasUser(username, true);
if (!userOrgs) {
ctx.body = {
uid: null,
};
return;
}
const usernameUser = await User.findOne({ where: { username } });
if (!usernameUser) {
ctx.body = {
uid: null,
};
return;
}
ctx.body = {
uid: usernameUser.id,
user: usernameUser,
};
})
.addTo(app);