fix: project role delete (#431)

This commit is contained in:
Fabi
2020-07-09 16:47:48 +02:00
committed by GitHub
parent f664ad7f88
commit cde6231164
2 changed files with 9 additions and 8 deletions

View File

@@ -340,13 +340,16 @@ func (es *ProjectEventstore) PrepareRemoveProjectRole(ctx context.Context, role
}
func (es *ProjectEventstore) RemoveRoleFromGrants(existing *model.Project, roleKey string) []*model.ProjectGrant {
grants := make([]*model.ProjectGrant, 0)
for _, grant := range existing.Grants {
grants := make([]*model.ProjectGrant, len(existing.Grants))
for i, grant := range existing.Grants {
roles := make([]string, 0)
for _, role := range grant.RoleKeys {
if role != roleKey {
grants = append(grants, grant)
roles = append(roles, role)
}
}
grant.RoleKeys = roles
grants[i] = grant
}
return grants
}