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