2021-01-04 14:52:13 +01:00
|
|
|
package iam
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-01-03 09:19:07 +01:00
|
|
|
|
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 (
|
|
|
|
PasswordAgePolicyAddedEventType = iamEventTypePrefix + policy.PasswordAgePolicyAddedEventType
|
|
|
|
PasswordAgePolicyChangedEventType = iamEventTypePrefix + policy.PasswordAgePolicyChangedEventType
|
|
|
|
)
|
|
|
|
|
|
|
|
type PasswordAgePolicyAddedEvent struct {
|
|
|
|
policy.PasswordAgePolicyAddedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPasswordAgePolicyAddedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-04 14:52:13 +01:00
|
|
|
expireWarnDays,
|
|
|
|
maxAgeDays uint64,
|
|
|
|
) *PasswordAgePolicyAddedEvent {
|
|
|
|
return &PasswordAgePolicyAddedEvent{
|
|
|
|
PasswordAgePolicyAddedEvent: *policy.NewPasswordAgePolicyAddedEvent(
|
2021-02-18 14:48:27 +01:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
PasswordAgePolicyAddedEventType),
|
2021-01-04 14:52:13 +01:00
|
|
|
expireWarnDays,
|
|
|
|
maxAgeDays),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func PasswordAgePolicyAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-01-04 14:52:13 +01:00
|
|
|
e, err := policy.PasswordAgePolicyAddedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &PasswordAgePolicyAddedEvent{PasswordAgePolicyAddedEvent: *e.(*policy.PasswordAgePolicyAddedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type PasswordAgePolicyChangedEvent struct {
|
|
|
|
policy.PasswordAgePolicyChangedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPasswordAgePolicyChangedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-18 11:24:15 +01:00
|
|
|
changes []policy.PasswordAgePolicyChanges,
|
|
|
|
) (*PasswordAgePolicyChangedEvent, error) {
|
|
|
|
changedEvent, err := policy.NewPasswordAgePolicyChangedEvent(
|
2021-02-18 14:48:27 +01:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
PasswordAgePolicyChangedEventType),
|
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 &PasswordAgePolicyChangedEvent{PasswordAgePolicyChangedEvent: *changedEvent}, nil
|
2021-01-04 14:52:13 +01:00
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func PasswordAgePolicyChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-01-04 14:52:13 +01:00
|
|
|
e, err := policy.PasswordAgePolicyChangedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &PasswordAgePolicyChangedEvent{PasswordAgePolicyChangedEvent: *e.(*policy.PasswordAgePolicyChangedEvent)}, nil
|
|
|
|
}
|