zitadel/internal/v2/repository/iam/policy_password_age.go

63 lines
1.8 KiB
Go
Raw Normal View History

package iam
import (
"context"
"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,
) *PasswordAgePolicyChangedEvent {
return &PasswordAgePolicyChangedEvent{
PasswordAgePolicyChangedEvent: *policy.NewPasswordAgePolicyChangedEvent(
eventstore.NewBaseEventForPush(ctx, PasswordAgePolicyChangedEventType),
),
}
}
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
}