2021-01-04 14:52:13 +01:00
|
|
|
package iam
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
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
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
PasswordLockoutPolicyAddedEventType = iamEventTypePrefix + policy.PasswordLockoutPolicyAddedEventType
|
|
|
|
PasswordLockoutPolicyChangedEventType = iamEventTypePrefix + policy.PasswordLockoutPolicyChangedEventType
|
|
|
|
)
|
|
|
|
|
|
|
|
type PasswordLockoutPolicyAddedEvent struct {
|
|
|
|
policy.PasswordLockoutPolicyAddedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPasswordLockoutPolicyAddedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-04 14:52:13 +01:00
|
|
|
maxAttempts uint64,
|
|
|
|
showLockoutFailure bool,
|
|
|
|
) *PasswordLockoutPolicyAddedEvent {
|
|
|
|
return &PasswordLockoutPolicyAddedEvent{
|
|
|
|
PasswordLockoutPolicyAddedEvent: *policy.NewPasswordLockoutPolicyAddedEvent(
|
2021-02-18 14:48:27 +01:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
PasswordLockoutPolicyAddedEventType),
|
2021-01-04 14:52:13 +01: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 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-18 11:24:15 +01:00
|
|
|
changes []policy.PasswordLockoutPolicyChanges,
|
|
|
|
) (*PasswordLockoutPolicyChangedEvent, error) {
|
|
|
|
changedEvent, err := policy.NewPasswordLockoutPolicyChangedEvent(
|
2021-02-18 14:48:27 +01:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
PasswordLockoutPolicyChangedEventType),
|
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 &PasswordLockoutPolicyChangedEvent{PasswordLockoutPolicyChangedEvent: *changedEvent}, nil
|
2021-01-04 14:52:13 +01: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
|
|
|
|
}
|