Преглед изворни кода

!90 【轻量级PR】SysUserController remove 解决把自己删除的bug
Merge pull request !90 from dazer007/secerity-fix-remove-self-ok

若依 пре 4 година
родитељ
комит
04edd66199

+ 5 - 0
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java

@@ -5,6 +5,8 @@ import java.util.List;
5 5
 import java.util.Set;
6 6
 import java.util.stream.Collectors;
7 7
 import javax.servlet.http.HttpServletResponse;
8
+
9
+import org.apache.commons.lang3.ArrayUtils;
8 10
 import org.springframework.beans.factory.annotation.Autowired;
9 11
 import org.springframework.validation.annotation.Validated;
10 12
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -217,6 +219,9 @@ public class SysUserController extends BaseController
217 219
     @DeleteMapping("/{userIds}")
218 220
     public AjaxResult remove(@PathVariable Long[] userIds)
219 221
     {
222
+        if (ArrayUtils.contains(userIds, SecurityUtils.getUserId())) {
223
+            return AjaxResult.error("当前用户不能删除");
224
+        }
220 225
         return toAjax(userService.deleteUserByIds(userIds));
221 226
     }
222 227