Skip to content

Commit

Permalink
Merge pull request #100 from TaleLin/fix-99
Browse files Browse the repository at this point in the history
fix: 删除用户接口(deleteUser) 不允许删除 root 分组的用户
  • Loading branch information
vanoneang authored Nov 25, 2020
2 parents 8006a52 + e7ac223 commit 12cda53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/config/code-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = {
10076: '邮箱已被使用,请重新填入新的邮箱',
10077: '不可将用户分配给不存在的分组',
10078: '不可修改root用户的分组',
10079: 'root分组的用户不可删除',
10080: '请求方法不允许',
10100: '刷新令牌获取失败',
10110: '{name}大小不能超过{size}字节',
Expand Down
11 changes: 11 additions & 0 deletions app/dao/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ class AdminDao {
code: 10021
});
}
const root = await UserGroupModel.findOne({
where: {
group_id: GroupLevel.Root,
user_id: id
}
})
if (root) {
throw new Forbidden({
code: 10079
})
}
let transaction;
try {
transaction = await sequelize.transaction();
Expand Down

0 comments on commit 12cda53

Please sign in to comment.