2020-11-12 21:50:01 +00:00
|
|
|
package org
|
|
|
|
|
|
|
|
import (
|
2021-01-04 13:52:13 +00:00
|
|
|
"context"
|
2022-01-03 08:19:07 +00:00
|
|
|
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
2021-02-18 13:48:27 +00:00
|
|
|
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/repository"
|
|
|
|
"github.com/caos/zitadel/internal/repository/policy"
|
2020-11-12 21:50:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2021-01-04 13:52:13 +00:00
|
|
|
PasswordComplexityPolicyAddedEventType = orgEventTypePrefix + policy.PasswordComplexityPolicyAddedEventType
|
|
|
|
PasswordComplexityPolicyChangedEventType = orgEventTypePrefix + policy.PasswordComplexityPolicyChangedEventType
|
2021-01-18 10:24:15 +00:00
|
|
|
PasswordComplexityPolicyRemovedEventType = orgEventTypePrefix + policy.PasswordComplexityPolicyRemovedEventType
|
2020-11-12 21:50:01 +00:00
|
|
|
)
|
|
|
|
|
2021-01-04 13:52:13 +00:00
|
|
|
type PasswordComplexityPolicyAddedEvent struct {
|
|
|
|
policy.PasswordComplexityPolicyAddedEvent
|
2020-11-12 21:50:01 +00:00
|
|
|
}
|
|
|
|
|
2021-01-04 13:52:13 +00:00
|
|
|
func NewPasswordComplexityPolicyAddedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-04 13:52:13 +00:00
|
|
|
minLength uint64,
|
|
|
|
hasLowercase,
|
|
|
|
hasUppercase,
|
|
|
|
hasNumber,
|
|
|
|
hasSymbol bool,
|
|
|
|
) *PasswordComplexityPolicyAddedEvent {
|
|
|
|
return &PasswordComplexityPolicyAddedEvent{
|
|
|
|
PasswordComplexityPolicyAddedEvent: *policy.NewPasswordComplexityPolicyAddedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
PasswordComplexityPolicyAddedEventType),
|
2021-01-04 13:52:13 +00:00
|
|
|
minLength,
|
|
|
|
hasLowercase,
|
|
|
|
hasUppercase,
|
|
|
|
hasNumber,
|
|
|
|
hasSymbol),
|
2020-11-12 21:50:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 08:19:07 +00:00
|
|
|
func PasswordComplexityPolicyAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-01-04 13:52:13 +00:00
|
|
|
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 {
|
2021-01-04 13:52:13 +00:00
|
|
|
policy.PasswordComplexityPolicyChangedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPasswordComplexityPolicyChangedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-18 10:24:15 +00:00
|
|
|
changes []policy.PasswordComplexityPolicyChanges,
|
|
|
|
) (*PasswordComplexityPolicyChangedEvent, error) {
|
|
|
|
changedEvent, err := policy.NewPasswordComplexityPolicyChangedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
PasswordComplexityPolicyChangedEventType),
|
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 &PasswordComplexityPolicyChangedEvent{PasswordComplexityPolicyChangedEvent: *changedEvent}, nil
|
2021-01-04 13:52:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-03 08:19:07 +00:00
|
|
|
func PasswordComplexityPolicyChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-01-04 13:52:13 +00:00
|
|
|
e, err := policy.PasswordComplexityPolicyChangedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &PasswordComplexityPolicyChangedEvent{PasswordComplexityPolicyChangedEvent: *e.(*policy.PasswordComplexityPolicyChangedEvent)}, nil
|
2020-11-12 21:50:01 +00:00
|
|
|
}
|
2021-01-18 10:24:15 +00:00
|
|
|
|
|
|
|
type PasswordComplexityPolicyRemovedEvent struct {
|
|
|
|
policy.PasswordComplexityPolicyRemovedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPasswordComplexityPolicyRemovedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-18 10:24:15 +00:00
|
|
|
) *PasswordComplexityPolicyRemovedEvent {
|
|
|
|
return &PasswordComplexityPolicyRemovedEvent{
|
|
|
|
PasswordComplexityPolicyRemovedEvent: *policy.NewPasswordComplexityPolicyRemovedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
PasswordComplexityPolicyRemovedEventType),
|
2021-01-18 10:24:15 +00:00
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 08:19:07 +00:00
|
|
|
func PasswordComplexityPolicyRemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-01-18 10:24:15 +00:00
|
|
|
e, err := policy.PasswordComplexityPolicyRemovedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &PasswordComplexityPolicyRemovedEvent{PasswordComplexityPolicyRemovedEvent: *e.(*policy.PasswordComplexityPolicyRemovedEvent)}, nil
|
|
|
|
}
|