[IMPROVE] Prevent "App user" from being deleted by the admin (#16373)

pull/16388/head
Shiqi Mei 6 years ago committed by GitHub
parent 530c545ece
commit 060bf9fb3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      packages/rocketchat-i18n/i18n/en.i18n.json
  2. 1
      packages/rocketchat-i18n/i18n/zh.i18n.json
  3. 6
      server/methods/deleteUser.js

@ -1276,6 +1276,7 @@
"error-archived-duplicate-name": "There's an archived channel with name '__room_name__'",
"error-avatar-invalid-url": "Invalid avatar URL: __url__",
"error-avatar-url-handling": "Error while handling avatar setting from a URL (__url__) for __username__",
"error-cannot-delete-app-user": "Deleting app user is not allowed, uninstall the corresponding app to remove it.",
"error-cant-invite-for-direct-room": "Can't invite user to direct rooms",
"error-channels-setdefault-is-same": "The channel default setting is the same as what it would be changed to.",
"error-channels-setdefault-missing-default-param": "The bodyParam 'default' is required",

@ -1232,6 +1232,7 @@
"error-archived-duplicate-name": "有一个名为 '__room_name__' 的已归档频道",
"error-avatar-invalid-url": "无效的头像地址:__url__",
"error-avatar-url-handling": "为用户 __username__ 从网址 (__url__) 处理头像时出错",
"error-cannot-delete-app-user": "不允许直接删除App用户”,请卸载相应的App以移除此用户。",
"error-cant-invite-for-direct-room": "不能邀请用户进入私聊房间",
"error-channels-setdefault-is-same": "频道的默认设置与更改的频道相同。",
"error-channels-setdefault-missing-default-param": "bodyParam 'default' 是必需的",

@ -28,6 +28,12 @@ Meteor.methods({
});
}
if (user.type === 'app') {
throw new Meteor.Error('error-cannot-delete-app-user', 'Deleting app user is not allowed', {
method: 'deleteUser',
});
}
const adminCount = Meteor.users.find({ roles: 'admin' }).count();
const userIsAdmin = user.roles.indexOf('admin') > -1;

Loading…
Cancel
Save