From 927288438147cffd8526b9409c78b0bdcdc3aadd Mon Sep 17 00:00:00 2001 From: JustSong Date: Thu, 27 Apr 2023 14:45:12 +0800 Subject: [PATCH] fix: root user cannot demote itself now (close #30) --- controller/user.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/controller/user.go b/controller/user.go index 2c32213a..02580dda 100644 --- a/controller/user.go +++ b/controller/user.go @@ -559,6 +559,13 @@ func ManageUser(c *gin.Context) { } user.Role = common.RoleAdminUser case "demote": + if user.Role == common.RoleRootUser { + c.JSON(http.StatusOK, gin.H{ + "success": false, + "message": "无法降级超级管理员用户", + }) + return + } user.Role = common.RoleCommonUser }