Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions pkg/user/UserCommonService.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,21 +258,13 @@ func (impl UserCommonServiceImpl) RemoveRolesAndReturnEliminatedPolicies(userInf
impl.logger.Errorw("Error in fetching roles by filter", "roleFilter", roleFilter)
return nil, err
}
oldRoleModel, err := impl.userAuthRepository.GetRoleByFilterForAllTypes(roleFilter.Entity, "", "", "", "", accessType, roleFilter.Cluster, namespace, group, kind, resource, actionType, true)
if err != nil {
return nil, err
}
if roleModel.Id == 0 && oldRoleModel.Id == 0 {
if roleModel.Id == 0 {
impl.logger.Warnw("no role found for given filter", "filter", roleFilter)
continue
}
if _, ok := existingRoleIds[roleModel.Id]; ok {
delete(eliminatedRoleIds, roleModel.Id)
}
if _, ok := existingRoleIds[oldRoleModel.Id]; ok {
//delete old role mapping from existing but not from eliminated roles (so that it gets deleted)
delete(existingRoleIds, oldRoleModel.Id)
}
}
}
}
Expand Down Expand Up @@ -321,7 +313,8 @@ func (impl UserCommonServiceImpl) RemoveRolesAndReturnEliminatedPolicies(userInf
if _, ok := existingRoleIds[roleModel.Id]; ok {
delete(eliminatedRoleIds, roleModel.Id)
}
if _, ok := existingRoleIds[oldRoleModel.Id]; ok {
isChartGroupEntity := roleFilter.Entity == bean.CHART_GROUP_ENTITY
if _, ok := existingRoleIds[oldRoleModel.Id]; ok && !isChartGroupEntity {
//delete old role mapping from existing but not from eliminated roles (so that it gets deleted)
delete(existingRoleIds, oldRoleModel.Id)
}
Expand Down