mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
fix: project role delete (#431)
This commit is contained in:
parent
f664ad7f88
commit
cde6231164
@ -2,19 +2,17 @@ package management
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/caos/zitadel/internal/api/authz"
|
||||
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
|
||||
grpc_util "github.com/caos/zitadel/internal/api/grpc"
|
||||
"github.com/caos/zitadel/internal/api/http"
|
||||
"github.com/caos/zitadel/pkg/grpc/management"
|
||||
)
|
||||
|
||||
func (s *Server) SearchProjectGrants(ctx context.Context, in *management.ProjectGrantSearchRequest) (*management.ProjectGrantSearchResponse, error) {
|
||||
request := projectGrantSearchRequestsToModel(in)
|
||||
orgID := grpc_util.GetHeader(ctx, http.ZitadelOrgID)
|
||||
request.AppendMyResourceOwnerQuery(orgID)
|
||||
request.AppendNotMyOrgQuery(orgID)
|
||||
ctxData := authz.GetCtxData(ctx)
|
||||
request.AppendMyResourceOwnerQuery(ctxData.OrgID)
|
||||
response, err := s.project.SearchProjectGrants(ctx, request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user