feat: add minio list detect
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user