diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index 1043d86aec..9c4aab264d 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -131,6 +131,10 @@ public class UserService { } public void deleteUser(String userId) { + SessionUser user = SessionUtils.getUser(); + if (StringUtils.equals(user.getId(), userId)) { + MSException.throwException(Translator.get("cannot_delete_current_user")); + } userMapper.deleteByPrimaryKey(userId); } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index e10d0175b2..64b1a1dfba 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -32,4 +32,5 @@ workspace_not_exists=Workspace is not exists #api api_load_script_error=Load script error user_id_already_exists=User ID already exists -password_modification_failed=Password modification failed \ No newline at end of file +password_modification_failed=Password modification failed +cannot_delete_current_user=Cannot delete the user currently logged in \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index c2da3003cd..4304cc53b2 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -32,4 +32,5 @@ workspace_not_exists=工作空间不存在 #api api_load_script_error=读取脚本失败 user_id_already_exists=用户id已存在 -password_modification_failed=密码修改失败 \ No newline at end of file +password_modification_failed=密码修改失败 +cannot_delete_current_user=无法删除当前登录用户 \ No newline at end of file