mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
c740ee5d81
* fix: add events for domain * fix: add/remove domain command side * fix: add/remove domain command side * fix: add/remove domain query side * fix: create instance * fix: merge v2 * fix: instance domain * fix: instance domain * fix: instance domain * fix: instance domain * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from api * fix: remove domain.IAMID * fix: remove domain.IAMID * fix: add instance domain queries * fix: fix after merge * Update auth_request.go * fix keypair * remove unused code * feat: read instance id from context * feat: remove unused code * feat: use instance id from context * some fixes Co-authored-by: Livio Amstutz <livio.a@gmail.com>
36 lines
1.5 KiB
Go
36 lines
1.5 KiB
Go
package command
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
"github.com/caos/zitadel/internal/query"
|
|
"github.com/caos/zitadel/internal/repository/instance"
|
|
"github.com/caos/zitadel/internal/repository/org"
|
|
"github.com/caos/zitadel/internal/repository/project"
|
|
)
|
|
|
|
func (c *Commands) removeUserMemberships(ctx context.Context, memberships []*query.Membership) (_ []eventstore.Command, err error) {
|
|
events := make([]eventstore.Command, 0)
|
|
for _, membership := range memberships {
|
|
if membership.IAM != nil {
|
|
iamAgg := instance.NewAggregate(membership.IAM.IAMID)
|
|
removeEvent := c.removeInstanceMember(ctx, &iamAgg.Aggregate, membership.UserID, true)
|
|
events = append(events, removeEvent)
|
|
} else if membership.Org != nil {
|
|
iamAgg := org.NewAggregate(membership.Org.OrgID, membership.ResourceOwner)
|
|
removeEvent := c.removeOrgMember(ctx, &iamAgg.Aggregate, membership.UserID, true)
|
|
events = append(events, removeEvent)
|
|
} else if membership.Project != nil {
|
|
projectAgg := project.NewAggregate(membership.Project.ProjectID, membership.ResourceOwner)
|
|
removeEvent := c.removeProjectMember(ctx, &projectAgg.Aggregate, membership.UserID, true)
|
|
events = append(events, removeEvent)
|
|
} else if membership.ProjectGrant != nil {
|
|
projectAgg := project.NewAggregate(membership.ProjectGrant.ProjectID, membership.ResourceOwner)
|
|
removeEvent := c.removeProjectGrantMember(ctx, &projectAgg.Aggregate, membership.UserID, membership.ProjectGrant.GrantID, true)
|
|
events = append(events, removeEvent)
|
|
}
|
|
}
|
|
return events, nil
|
|
}
|