2020-11-12 21:50:01 +00:00
|
|
|
package iam
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
2020-11-30 05:40:56 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
2020-11-12 21:50:01 +00:00
|
|
|
"github.com/caos/zitadel/internal/v2/repository/policy"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
PasswordComplexityPolicyAddedEventType = iamEventTypePrefix + policy.PasswordComplexityPolicyAddedEventType
|
|
|
|
PasswordComplexityPolicyChangedEventType = iamEventTypePrefix + policy.PasswordComplexityPolicyChangedEventType
|
|
|
|
)
|
|
|
|
|
|
|
|
type PasswordComplexityPolicyReadModel struct {
|
|
|
|
policy.PasswordComplexityPolicyReadModel
|
|
|
|
}
|
|
|
|
|
2020-11-25 13:12:44 +00:00
|
|
|
func (rm *PasswordComplexityPolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
|
2020-11-12 21:50:01 +00:00
|
|
|
for _, event := range events {
|
|
|
|
switch e := event.(type) {
|
|
|
|
case *PasswordComplexityPolicyAddedEvent:
|
|
|
|
rm.ReadModel.AppendEvents(&e.PasswordComplexityPolicyAddedEvent)
|
|
|
|
case *PasswordComplexityPolicyChangedEvent:
|
|
|
|
rm.ReadModel.AppendEvents(&e.PasswordComplexityPolicyChangedEvent)
|
2020-11-26 12:14:07 +00:00
|
|
|
case *policy.PasswordComplexityPolicyAddedEvent,
|
|
|
|
*policy.PasswordComplexityPolicyChangedEvent:
|
|
|
|
|
2020-11-12 21:50:01 +00:00
|
|
|
rm.ReadModel.AppendEvents(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type PasswordComplexityPolicyAddedEvent struct {
|
|
|
|
policy.PasswordComplexityPolicyAddedEvent
|
|
|
|
}
|
|
|
|
|
2020-11-30 05:40:56 +00:00
|
|
|
func PasswordComplexityPolicyAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
e, err := policy.PasswordComplexityPolicyAddedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &PasswordComplexityPolicyAddedEvent{PasswordComplexityPolicyAddedEvent: *e.(*policy.PasswordComplexityPolicyAddedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
2020-11-12 21:50:01 +00:00
|
|
|
type PasswordComplexityPolicyChangedEvent struct {
|
|
|
|
policy.PasswordComplexityPolicyChangedEvent
|
|
|
|
}
|
2020-11-30 05:40:56 +00:00
|
|
|
|
|
|
|
func PasswordComplexityPolicyChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
e, err := policy.PasswordComplexityPolicyChangedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &PasswordComplexityPolicyChangedEvent{PasswordComplexityPolicyChangedEvent: *e.(*policy.PasswordComplexityPolicyChangedEvent)}, nil
|
|
|
|
}
|