zitadel/internal/repository/instance/policy_password_age.go
Florian Forster fa9f581d56
chore(v2): move to new org (#3499)
* chore: move to new org

* logging

* fix: org rename caos -> zitadel

Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
2022-04-26 23:01:45 +00:00

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
}