fix: fix no user type for admin user to group
This commit is contained in:
@@ -30,12 +30,17 @@ app
|
||||
const tokenAdmin = ctx.state.tokenAdmin;
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const data = ctx.query.data;
|
||||
const { orgId, userId, action } = data;
|
||||
const { orgId, userId, username, action, role } = data;
|
||||
const org = await Org.findByPk(orgId);
|
||||
if (!org) {
|
||||
ctx.throw('组织不存在');
|
||||
}
|
||||
const user = await User.findByPk(userId);
|
||||
let user: User;
|
||||
if (userId) {
|
||||
user = await User.findByPk(userId);
|
||||
} else if (username) {
|
||||
user = await User.findOne({ where: { username } });
|
||||
}
|
||||
if (!user) {
|
||||
ctx.throw('用户不存在');
|
||||
}
|
||||
@@ -44,7 +49,7 @@ app
|
||||
}
|
||||
const operateId = tokenUser.uid || tokenUser.id;
|
||||
if (action === 'add') {
|
||||
await org.addUser(user, { needPermission: true, role: 'user', operateId, isAdmin: !!tokenAdmin });
|
||||
await org.addUser(user, { needPermission: true, role: role || 'user', operateId, isAdmin: !!tokenAdmin });
|
||||
} else if (action === 'remove') {
|
||||
await org.removeUser(user, { needPermission: true, operateId, isAdmin: !!tokenAdmin });
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user