Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/zh.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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' 是必需的",
Expand Down
6 changes: 6 additions & 0 deletions server/methods/deleteUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down