mirror of
https://github.com/zitadel/zitadel
synced 2024-11-23 11:12:21 +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.1 KiB
Go
77 lines
2.1 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 (
|
|
PasswordAgePolicyAddedEventType = instanceEventTypePrefix + policy.PasswordAgePolicyAddedEventType
|
|
PasswordAgePolicyChangedEventType = instanceEventTypePrefix + policy.PasswordAgePolicyChangedEventType
|
|
)
|
|
|
|
type PasswordAgePolicyAddedEvent struct {
|
|
policy.PasswordAgePolicyAddedEvent
|
|
}
|
|
|
|
func NewPasswordAgePolicyAddedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
expireWarnDays,
|
|
maxAgeDays uint64,
|
|
) *PasswordAgePolicyAddedEvent {
|
|
return &PasswordAgePolicyAddedEvent{
|
|
PasswordAgePolicyAddedEvent: *policy.NewPasswordAgePolicyAddedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
PasswordAgePolicyAddedEventType),
|
|
expireWarnDays,
|
|
maxAgeDays),
|
|
}
|
|
}
|
|
|
|
func PasswordAgePolicyAddedEventMapper(event *repository.Event) (eventstore.Event, 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,
|
|
aggregate *eventstore.Aggregate,
|
|
changes []policy.PasswordAgePolicyChanges,
|
|
) (*PasswordAgePolicyChangedEvent, error) {
|
|
changedEvent, err := policy.NewPasswordAgePolicyChangedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
PasswordAgePolicyChangedEventType),
|
|
changes,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &PasswordAgePolicyChangedEvent{PasswordAgePolicyChangedEvent: *changedEvent}, nil
|
|
}
|
|
|
|
func PasswordAgePolicyChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
|
e, err := policy.PasswordAgePolicyChangedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &PasswordAgePolicyChangedEvent{PasswordAgePolicyChangedEvent: *e.(*policy.PasswordAgePolicyChangedEvent)}, nil
|
|
}
|