From 0a0c1b47881addb25778df8ff5e43a12a90f18b2 Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Thu, 13 Jul 2023 00:03:18 +0800 Subject: [PATCH] Fix "Groups is immutable" bug when updating a user --- object/user_util.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/object/user_util.go b/object/user_util.go index 1771e775..75588272 100644 --- a/object/user_util.go +++ b/object/user_util.go @@ -293,7 +293,13 @@ func CheckPermissionForUpdateUser(oldUser, newUser *User, isAdmin bool, lang str itemsChanged = append(itemsChanged, item) } + if oldUser.Groups == nil { + oldUser.Groups = []string{} + } oldUserGroupsJson, _ := json.Marshal(oldUser.Groups) + if newUser.Groups == nil { + newUser.Groups = []string{} + } newUserGroupsJson, _ := json.Marshal(newUser.Groups) if string(oldUserGroupsJson) != string(newUserGroupsJson) { item := GetAccountItemByName("Groups", organization)