2021-01-04 13:52:13 +00:00
|
|
|
package iam
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-01-18 10:24:15 +00:00
|
|
|
|
2021-01-04 13:52:13 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
|
|
|
"github.com/caos/zitadel/internal/v2/repository/policy"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
PasswordAgePolicyAddedEventType = iamEventTypePrefix + policy.PasswordAgePolicyAddedEventType
|
|
|
|
PasswordAgePolicyChangedEventType = iamEventTypePrefix + policy.PasswordAgePolicyChangedEventType
|
|
|
|
)
|
|
|
|
|
|
|
|
type PasswordAgePolicyAddedEvent struct {
|
|
|
|
policy.PasswordAgePolicyAddedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPasswordAgePolicyAddedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
expireWarnDays,
|
|
|
|
maxAgeDays uint64,
|
|
|
|
) *PasswordAgePolicyAddedEvent {
|
|
|
|
return &PasswordAgePolicyAddedEvent{
|
|
|
|
PasswordAgePolicyAddedEvent: *policy.NewPasswordAgePolicyAddedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(ctx, PasswordAgePolicyAddedEventType),
|
|
|
|
expireWarnDays,
|
|
|
|
maxAgeDays),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func PasswordAgePolicyAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
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-01-18 10:24:15 +00:00
|
|
|
changes []policy.PasswordAgePolicyChanges,
|
|
|
|
) (*PasswordAgePolicyChangedEvent, error) {
|
|
|
|
changedEvent, err := policy.NewPasswordAgePolicyChangedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(ctx, PasswordAgePolicyChangedEventType),
|
|
|
|
changes,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2021-01-04 13:52:13 +00:00
|
|
|
}
|
2021-01-18 10:24:15 +00:00
|
|
|
return &PasswordAgePolicyChangedEvent{PasswordAgePolicyChangedEvent: *changedEvent}, nil
|
2021-01-04 13:52:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func PasswordAgePolicyChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
e, err := policy.PasswordAgePolicyChangedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &PasswordAgePolicyChangedEvent{PasswordAgePolicyChangedEvent: *e.(*policy.PasswordAgePolicyChangedEvent)}, nil
|
|
|
|
}
|