mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
77 lines
2.0 KiB
Go
77 lines
2.0 KiB
Go
package instance
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
|
"github.com/zitadel/zitadel/internal/repository/policy"
|
|
)
|
|
|
|
var (
|
|
LockoutPolicyAddedEventType = instanceEventTypePrefix + policy.LockoutPolicyAddedEventType
|
|
LockoutPolicyChangedEventType = instanceEventTypePrefix + policy.LockoutPolicyChangedEventType
|
|
)
|
|
|
|
type LockoutPolicyAddedEvent struct {
|
|
policy.LockoutPolicyAddedEvent
|
|
}
|
|
|
|
func NewLockoutPolicyAddedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
maxAttempts uint64,
|
|
showLockoutFailure bool,
|
|
) *LockoutPolicyAddedEvent {
|
|
return &LockoutPolicyAddedEvent{
|
|
LockoutPolicyAddedEvent: *policy.NewLockoutPolicyAddedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
LockoutPolicyAddedEventType),
|
|
maxAttempts,
|
|
showLockoutFailure),
|
|
}
|
|
}
|
|
|
|
func LockoutPolicyAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
|
e, err := policy.LockoutPolicyAddedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &LockoutPolicyAddedEvent{LockoutPolicyAddedEvent: *e.(*policy.LockoutPolicyAddedEvent)}, nil
|
|
}
|
|
|
|
type LockoutPolicyChangedEvent struct {
|
|
policy.LockoutPolicyChangedEvent
|
|
}
|
|
|
|
func NewLockoutPolicyChangedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
changes []policy.LockoutPolicyChanges,
|
|
) (*LockoutPolicyChangedEvent, error) {
|
|
changedEvent, err := policy.NewLockoutPolicyChangedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
LockoutPolicyChangedEventType),
|
|
changes,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &LockoutPolicyChangedEvent{LockoutPolicyChangedEvent: *changedEvent}, nil
|
|
}
|
|
|
|
func LockoutPolicyChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
|
e, err := policy.LockoutPolicyChangedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &LockoutPolicyChangedEvent{LockoutPolicyChangedEvent: *e.(*policy.LockoutPolicyChangedEvent)}, nil
|
|
}
|