mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 18:54:03 +08:00
feat: fix checkPermissionForUpdateUser()
logic (#1454)
* fix: fix `checkPermissionForUpdateUser()` logic * fix: fix `checkPermissionForUpdateUser()` logic
This commit is contained in:
parent
dcf148fb7f
commit
4ab2ca7a25
@ -17,7 +17,6 @@ package controllers
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/beego/beego/utils/pagination"
|
"github.com/beego/beego/utils/pagination"
|
||||||
@ -200,18 +199,28 @@ func checkPermissionForUpdateUser(id string, newUser object.User, c *ApiControll
|
|||||||
item := object.GetAccountItemByName("Signup application", org)
|
item := object.GetAccountItemByName("Signup application", org)
|
||||||
itemsChanged = append(itemsChanged, item)
|
itemsChanged = append(itemsChanged, item)
|
||||||
}
|
}
|
||||||
if reflect.DeepEqual(oldUser.Roles, newUser.Roles) {
|
|
||||||
|
oldUserRolesJson, _ := json.Marshal(oldUser.Roles)
|
||||||
|
newUserRolesJson, _ := json.Marshal(newUser.Roles)
|
||||||
|
if string(oldUserRolesJson) != string(newUserRolesJson) {
|
||||||
item := object.GetAccountItemByName("Roles", org)
|
item := object.GetAccountItemByName("Roles", org)
|
||||||
itemsChanged = append(itemsChanged, item)
|
itemsChanged = append(itemsChanged, item)
|
||||||
}
|
}
|
||||||
if reflect.DeepEqual(oldUser.Permissions, newUser.Permissions) {
|
|
||||||
|
oldUserPermissionJson, _ := json.Marshal(oldUser.Permissions)
|
||||||
|
newUserPermissionJson, _ := json.Marshal(newUser.Permissions)
|
||||||
|
if string(oldUserPermissionJson) != string(newUserPermissionJson) {
|
||||||
item := object.GetAccountItemByName("Permissions", org)
|
item := object.GetAccountItemByName("Permissions", org)
|
||||||
itemsChanged = append(itemsChanged, item)
|
itemsChanged = append(itemsChanged, item)
|
||||||
}
|
}
|
||||||
if reflect.DeepEqual(oldUser.Properties, newUser.Properties) {
|
|
||||||
|
oldUserPropertiesJson, _ := json.Marshal(oldUser.Properties)
|
||||||
|
newUserPropertiesJson, _ := json.Marshal(newUser.Properties)
|
||||||
|
if string(oldUserPropertiesJson) != string(newUserPropertiesJson) {
|
||||||
item := object.GetAccountItemByName("Properties", org)
|
item := object.GetAccountItemByName("Properties", org)
|
||||||
itemsChanged = append(itemsChanged, item)
|
itemsChanged = append(itemsChanged, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
if oldUser.IsAdmin != newUser.IsAdmin {
|
if oldUser.IsAdmin != newUser.IsAdmin {
|
||||||
item := object.GetAccountItemByName("Is admin", org)
|
item := object.GetAccountItemByName("Is admin", org)
|
||||||
itemsChanged = append(itemsChanged, item)
|
itemsChanged = append(itemsChanged, item)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user