2021-01-04 14:52:13 +01:00
|
|
|
package iam
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-01-03 09:19:07 +01:00
|
|
|
|
2021-02-23 15:13:04 +01:00
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
2021-01-18 11:24:15 +01:00
|
|
|
|
2021-02-23 15:13:04 +01:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/repository"
|
|
|
|
"github.com/caos/zitadel/internal/repository/policy"
|
2021-01-04 14:52:13 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
PasswordComplexityPolicyAddedEventType = iamEventTypePrefix + policy.PasswordComplexityPolicyAddedEventType
|
|
|
|
PasswordComplexityPolicyChangedEventType = iamEventTypePrefix + policy.PasswordComplexityPolicyChangedEventType
|
|
|
|
)
|
|
|
|
|
|
|
|
type PasswordComplexityPolicyAddedEvent struct {
|
|
|
|
policy.PasswordComplexityPolicyAddedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPasswordComplexityPolicyAddedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-04 14:52:13 +01:00
|
|
|
minLength uint64,
|
|
|
|
hasLowercase,
|
|
|
|
hasUppercase,
|
|
|
|
hasNumber,
|
|
|
|
hasSymbol bool,
|
|
|
|
) *PasswordComplexityPolicyAddedEvent {
|
|
|
|
return &PasswordComplexityPolicyAddedEvent{
|
|
|
|
PasswordComplexityPolicyAddedEvent: *policy.NewPasswordComplexityPolicyAddedEvent(
|
2021-02-18 14:48:27 +01:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
PasswordComplexityPolicyAddedEventType),
|
2021-01-04 14:52:13 +01:00
|
|
|
minLength,
|
|
|
|
hasLowercase,
|
|
|
|
hasUppercase,
|
|
|
|
hasNumber,
|
|
|
|
hasSymbol),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func PasswordComplexityPolicyAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-01-04 14:52:13 +01:00
|
|
|
e, err := policy.PasswordComplexityPolicyAddedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &PasswordComplexityPolicyAddedEvent{PasswordComplexityPolicyAddedEvent: *e.(*policy.PasswordComplexityPolicyAddedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type PasswordComplexityPolicyChangedEvent struct {
|
|
|
|
policy.PasswordComplexityPolicyChangedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPasswordComplexityPolicyChangedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-18 11:24:15 +01:00
|
|
|
changes []policy.PasswordComplexityPolicyChanges,
|
|
|
|
) (*PasswordComplexityPolicyChangedEvent, error) {
|
|
|
|
changedEvent, err := policy.NewPasswordComplexityPolicyChangedEvent(
|
2021-02-18 14:48:27 +01:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
PasswordComplexityPolicyChangedEventType),
|
2021-01-18 11:24:15 +01:00
|
|
|
changes,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2021-01-04 14:52:13 +01:00
|
|
|
}
|
2021-01-18 11:24:15 +01:00
|
|
|
return &PasswordComplexityPolicyChangedEvent{PasswordComplexityPolicyChangedEvent: *changedEvent}, nil
|
2021-01-04 14:52:13 +01:00
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func PasswordComplexityPolicyChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-01-04 14:52:13 +01:00
|
|
|
e, err := policy.PasswordComplexityPolicyChangedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &PasswordComplexityPolicyChangedEvent{PasswordComplexityPolicyChangedEvent: *e.(*policy.PasswordComplexityPolicyChangedEvent)}, nil
|
|
|
|
}
|