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 (
|
|
|
|
PasswordLockoutPolicyAddedEventType = iamEventTypePrefix + policy.PasswordLockoutPolicyAddedEventType
|
|
|
|
PasswordLockoutPolicyChangedEventType = iamEventTypePrefix + policy.PasswordLockoutPolicyChangedEventType
|
|
|
|
)
|
|
|
|
|
|
|
|
type PasswordLockoutPolicyAddedEvent struct {
|
|
|
|
policy.PasswordLockoutPolicyAddedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPasswordLockoutPolicyAddedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-04 13:52:13 +00:00
|
|
|
maxAttempts uint64,
|
|
|
|
showLockoutFailure bool,
|
|
|
|
) *PasswordLockoutPolicyAddedEvent {
|
|
|
|
return &PasswordLockoutPolicyAddedEvent{
|
|
|
|
PasswordLockoutPolicyAddedEvent: *policy.NewPasswordLockoutPolicyAddedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
PasswordLockoutPolicyAddedEventType),
|
2021-01-04 13:52:13 +00:00
|
|
|
maxAttempts,
|
|
|
|
showLockoutFailure),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func PasswordLockoutPolicyAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
e, err := policy.PasswordLockoutPolicyAddedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &PasswordLockoutPolicyAddedEvent{PasswordLockoutPolicyAddedEvent: *e.(*policy.PasswordLockoutPolicyAddedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type PasswordLockoutPolicyChangedEvent struct {
|
|
|
|
policy.PasswordLockoutPolicyChangedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPasswordLockoutPolicyChangedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-18 10:24:15 +00:00
|
|
|
changes []policy.PasswordLockoutPolicyChanges,
|
|
|
|
) (*PasswordLockoutPolicyChangedEvent, error) {
|
|
|
|
changedEvent, err := policy.NewPasswordLockoutPolicyChangedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
PasswordLockoutPolicyChangedEventType),
|
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 &PasswordLockoutPolicyChangedEvent{PasswordLockoutPolicyChangedEvent: *changedEvent}, nil
|
2021-01-04 13:52:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func PasswordLockoutPolicyChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
e, err := policy.PasswordLockoutPolicyChangedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &PasswordLockoutPolicyChangedEvent{PasswordLockoutPolicyChangedEvent: *e.(*policy.PasswordLockoutPolicyChangedEvent)}, nil
|
|
|
|
}
|