Browse Source

fix: root user cannot demote itself now (close #30)

JustSong 2 years ago
parent
commit
9272884381
1 changed files with 7 additions and 0 deletions
  1. 7 0
      controller/user.go

+ 7 - 0
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
 	}