fix: update sidebar modules role check
This commit is contained in:
@@ -664,18 +664,7 @@ func UpdateSelf(c *gin.Context) {
|
|||||||
if sidebarModules, exists := requestData["sidebar_modules"]; exists {
|
if sidebarModules, exists := requestData["sidebar_modules"]; exists {
|
||||||
userId := c.GetInt("id")
|
userId := c.GetInt("id")
|
||||||
userRole := c.GetInt("role")
|
userRole := c.GetInt("role")
|
||||||
// 注意超级管理员目前在 calculateUserPermissions 中被设置为无权更新设置
|
if userRole != common.RoleRootUser && userRole != common.RoleAdminUser {
|
||||||
perms := calculateUserPermissions(userRole)
|
|
||||||
allow, ok := perms["sidebar_settings"]
|
|
||||||
if !ok {
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"success": false,
|
|
||||||
"message": "无权更新设置",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
allowBool, ok := allow.(bool)
|
|
||||||
if !ok || !allowBool {
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"message": "无权更新设置",
|
"message": "无权更新设置",
|
||||||
|
|||||||
Reference in New Issue
Block a user