Skip to content

Commit 12cda53

Browse files
authored
Merge pull request #100 from TaleLin/fix-99
fix: 删除用户接口(deleteUser) 不允许删除 root 分组的用户
2 parents 8006a52 + e7ac223 commit 12cda53

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

app/config/code-message.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module.exports = {
5656
10076: '邮箱已被使用,请重新填入新的邮箱',
5757
10077: '不可将用户分配给不存在的分组',
5858
10078: '不可修改root用户的分组',
59+
10079: 'root分组的用户不可删除',
5960
10080: '请求方法不允许',
6061
10100: '刷新令牌获取失败',
6162
10110: '{name}大小不能超过{size}字节',

app/dao/admin.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ class AdminDao {
102102
code: 10021
103103
});
104104
}
105+
const root = await UserGroupModel.findOne({
106+
where: {
107+
group_id: GroupLevel.Root,
108+
user_id: id
109+
}
110+
})
111+
if (root) {
112+
throw new Forbidden({
113+
code: 10079
114+
})
115+
}
105116
let transaction;
106117
try {
107118
transaction = await sequelize.transaction();

0 commit comments

Comments
 (0)