mirror of
https://github.com/zitadel/zitadel.git
synced 2025-04-15 20:41:30 +00:00
fix: project role delete (#431)
This commit is contained in:
parent
f664ad7f88
commit
cde6231164
@ -2,19 +2,17 @@ package management
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/caos/zitadel/internal/api/authz"
|
||||||
|
|
||||||
"github.com/golang/protobuf/ptypes/empty"
|
"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"
|
"github.com/caos/zitadel/pkg/grpc/management"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Server) SearchProjectGrants(ctx context.Context, in *management.ProjectGrantSearchRequest) (*management.ProjectGrantSearchResponse, error) {
|
func (s *Server) SearchProjectGrants(ctx context.Context, in *management.ProjectGrantSearchRequest) (*management.ProjectGrantSearchResponse, error) {
|
||||||
request := projectGrantSearchRequestsToModel(in)
|
request := projectGrantSearchRequestsToModel(in)
|
||||||
orgID := grpc_util.GetHeader(ctx, http.ZitadelOrgID)
|
ctxData := authz.GetCtxData(ctx)
|
||||||
request.AppendMyResourceOwnerQuery(orgID)
|
request.AppendMyResourceOwnerQuery(ctxData.OrgID)
|
||||||
request.AppendNotMyOrgQuery(orgID)
|
|
||||||
response, err := s.project.SearchProjectGrants(ctx, request)
|
response, err := s.project.SearchProjectGrants(ctx, request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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 {
|
func (es *ProjectEventstore) RemoveRoleFromGrants(existing *model.Project, roleKey string) []*model.ProjectGrant {
|
||||||
grants := make([]*model.ProjectGrant, 0)
|
grants := make([]*model.ProjectGrant, len(existing.Grants))
|
||||||
for _, grant := range existing.Grants {
|
for i, grant := range existing.Grants {
|
||||||
|
roles := make([]string, 0)
|
||||||
for _, role := range grant.RoleKeys {
|
for _, role := range grant.RoleKeys {
|
||||||
if role != roleKey {
|
if role != roleKey {
|
||||||
grants = append(grants, grant)
|
roles = append(roles, role)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
grant.RoleKeys = roles
|
||||||
|
grants[i] = grant
|
||||||
}
|
}
|
||||||
return grants
|
return grants
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user