mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
fix: fix infinite loop in containsRole() (#2136)
This commit is contained in:
parent
6986dad295
commit
55d5ae10f2
@ -391,10 +391,13 @@ func GetAncestorRoles(roleIds ...string) ([]*Role, error) {
|
||||
|
||||
// containsRole is a helper function to check if a roles is related to any role in the given list roles
|
||||
func containsRole(role *Role, roleMap map[string]*Role, visited map[string]bool, roleIds ...string) bool {
|
||||
if isContain, ok := visited[role.GetId()]; ok {
|
||||
roleId := role.GetId()
|
||||
if isContain, ok := visited[roleId]; ok {
|
||||
return isContain
|
||||
}
|
||||
|
||||
visited[role.GetId()] = false
|
||||
|
||||
for _, subRole := range role.Roles {
|
||||
if util.HasString(roleIds, subRole) {
|
||||
return true
|
||||
|
Loading…
x
Reference in New Issue
Block a user