2021-01-04 13:52:13 +00:00
|
|
|
package iam
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
2021-01-18 10:24:15 +00:00
|
|
|
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/repository"
|
|
|
|
"github.com/caos/zitadel/internal/repository/policy"
|
2021-01-04 13:52:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
OrgIAMPolicyAddedEventType = iamEventTypePrefix + policy.OrgIAMPolicyAddedEventType
|
|
|
|
OrgIAMPolicyChangedEventType = iamEventTypePrefix + policy.OrgIAMPolicyChangedEventType
|
|
|
|
)
|
|
|
|
|
|
|
|
type OrgIAMPolicyAddedEvent struct {
|
|
|
|
policy.OrgIAMPolicyAddedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewOrgIAMPolicyAddedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-04 13:52:13 +00:00
|
|
|
userLoginMustBeDomain bool,
|
|
|
|
) *OrgIAMPolicyAddedEvent {
|
|
|
|
return &OrgIAMPolicyAddedEvent{
|
|
|
|
OrgIAMPolicyAddedEvent: *policy.NewOrgIAMPolicyAddedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
OrgIAMPolicyAddedEventType),
|
2021-01-04 13:52:13 +00:00
|
|
|
userLoginMustBeDomain,
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func OrgIAMPolicyAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
e, err := policy.OrgIAMPolicyAddedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &OrgIAMPolicyAddedEvent{OrgIAMPolicyAddedEvent: *e.(*policy.OrgIAMPolicyAddedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type OrgIAMPolicyChangedEvent struct {
|
|
|
|
policy.OrgIAMPolicyChangedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewOrgIAMPolicyChangedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-18 10:24:15 +00:00
|
|
|
changes []policy.OrgIAMPolicyChanges,
|
|
|
|
) (*OrgIAMPolicyChangedEvent, error) {
|
|
|
|
changedEvent, err := policy.NewOrgIAMPolicyChangedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
OrgIAMPolicyChangedEventType),
|
2021-01-18 10:24:15 +00:00
|
|
|
changes,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2021-01-04 13:52:13 +00:00
|
|
|
}
|
2021-01-18 10:24:15 +00:00
|
|
|
return &OrgIAMPolicyChangedEvent{OrgIAMPolicyChangedEvent: *changedEvent}, nil
|
2021-01-04 13:52:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func OrgIAMPolicyChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
e, err := policy.OrgIAMPolicyChangedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &OrgIAMPolicyChangedEvent{OrgIAMPolicyChangedEvent: *e.(*policy.OrgIAMPolicyChangedEvent)}, nil
|
|
|
|
}
|