2020-11-12 21:50:01 +00:00
|
|
|
package org
|
|
|
|
|
|
|
|
import (
|
2021-01-18 10:24:15 +00:00
|
|
|
"context"
|
2022-01-03 08:19:07 +00:00
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
2021-01-18 10:24:15 +00:00
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
|
|
|
"github.com/zitadel/zitadel/internal/repository/policy"
|
2020-11-12 21:50:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2021-08-11 06:36:32 +00:00
|
|
|
LockoutPolicyAddedEventType = orgEventTypePrefix + policy.LockoutPolicyAddedEventType
|
|
|
|
LockoutPolicyChangedEventType = orgEventTypePrefix + policy.LockoutPolicyChangedEventType
|
|
|
|
LockoutPolicyRemovedEventType = orgEventTypePrefix + policy.LockoutPolicyRemovedEventType
|
2020-11-12 21:50:01 +00:00
|
|
|
)
|
|
|
|
|
2021-08-11 06:36:32 +00:00
|
|
|
type LockoutPolicyAddedEvent struct {
|
|
|
|
policy.LockoutPolicyAddedEvent
|
2020-11-12 21:50:01 +00:00
|
|
|
}
|
|
|
|
|
2021-08-11 06:36:32 +00:00
|
|
|
func NewLockoutPolicyAddedEvent(
|
2021-01-18 10:24:15 +00:00
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-18 10:24:15 +00:00
|
|
|
maxAttempts uint64,
|
|
|
|
showLockoutFailure bool,
|
2021-08-11 06:36:32 +00:00
|
|
|
) *LockoutPolicyAddedEvent {
|
|
|
|
return &LockoutPolicyAddedEvent{
|
|
|
|
LockoutPolicyAddedEvent: *policy.NewLockoutPolicyAddedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
2021-08-11 06:36:32 +00:00
|
|
|
LockoutPolicyAddedEventType),
|
2021-01-18 10:24:15 +00:00
|
|
|
maxAttempts,
|
|
|
|
showLockoutFailure),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 08:19:07 +00:00
|
|
|
func LockoutPolicyAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-08-11 06:36:32 +00:00
|
|
|
e, err := policy.LockoutPolicyAddedEventMapper(event)
|
2021-01-18 10:24:15 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-08-11 06:36:32 +00:00
|
|
|
return &LockoutPolicyAddedEvent{LockoutPolicyAddedEvent: *e.(*policy.LockoutPolicyAddedEvent)}, nil
|
2021-01-18 10:24:15 +00:00
|
|
|
}
|
|
|
|
|
2021-08-11 06:36:32 +00:00
|
|
|
type LockoutPolicyChangedEvent struct {
|
|
|
|
policy.LockoutPolicyChangedEvent
|
2020-11-12 21:50:01 +00:00
|
|
|
}
|
2021-01-18 10:24:15 +00:00
|
|
|
|
2021-08-11 06:36:32 +00:00
|
|
|
func NewLockoutPolicyChangedEvent(
|
2021-01-18 10:24:15 +00:00
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-08-11 06:36:32 +00:00
|
|
|
changes []policy.LockoutPolicyChanges,
|
|
|
|
) (*LockoutPolicyChangedEvent, error) {
|
|
|
|
changedEvent, err := policy.NewLockoutPolicyChangedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
2021-08-11 06:36:32 +00:00
|
|
|
LockoutPolicyChangedEventType),
|
2021-01-18 10:24:15 +00:00
|
|
|
changes,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-08-11 06:36:32 +00:00
|
|
|
return &LockoutPolicyChangedEvent{LockoutPolicyChangedEvent: *changedEvent}, nil
|
2021-01-18 10:24:15 +00:00
|
|
|
}
|
|
|
|
|
2022-01-03 08:19:07 +00:00
|
|
|
func LockoutPolicyChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-08-11 06:36:32 +00:00
|
|
|
e, err := policy.LockoutPolicyChangedEventMapper(event)
|
2021-01-18 10:24:15 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-08-11 06:36:32 +00:00
|
|
|
return &LockoutPolicyChangedEvent{LockoutPolicyChangedEvent: *e.(*policy.LockoutPolicyChangedEvent)}, nil
|
2021-01-18 10:24:15 +00:00
|
|
|
}
|
|
|
|
|
2021-08-11 06:36:32 +00:00
|
|
|
type LockoutPolicyRemovedEvent struct {
|
|
|
|
policy.LockoutPolicyRemovedEvent
|
2021-01-18 10:24:15 +00:00
|
|
|
}
|
|
|
|
|
2021-08-11 06:36:32 +00:00
|
|
|
func NewLockoutPolicyRemovedEvent(
|
2021-01-18 10:24:15 +00:00
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-08-11 06:36:32 +00:00
|
|
|
) *LockoutPolicyRemovedEvent {
|
|
|
|
return &LockoutPolicyRemovedEvent{
|
|
|
|
LockoutPolicyRemovedEvent: *policy.NewLockoutPolicyRemovedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
2021-08-11 06:36:32 +00:00
|
|
|
LockoutPolicyRemovedEventType),
|
2021-01-18 10:24:15 +00:00
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 08:19:07 +00:00
|
|
|
func LockoutPolicyRemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-08-11 06:36:32 +00:00
|
|
|
e, err := policy.LockoutPolicyRemovedEventMapper(event)
|
2021-01-18 10:24:15 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-08-11 06:36:32 +00:00
|
|
|
return &LockoutPolicyRemovedEvent{LockoutPolicyRemovedEvent: *e.(*policy.LockoutPolicyRemovedEvent)}, nil
|
2021-01-18 10:24:15 +00:00
|
|
|
}
|