mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 20:08:02 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
83 lines
2.4 KiB
Go
83 lines
2.4 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"
|
|
)
|
|
|
|
const (
|
|
PasswordComplexityPolicyAddedEventType = instanceEventTypePrefix + policy.PasswordComplexityPolicyAddedEventType
|
|
PasswordComplexityPolicyChangedEventType = instanceEventTypePrefix + policy.PasswordComplexityPolicyChangedEventType
|
|
)
|
|
|
|
type PasswordComplexityPolicyAddedEvent struct {
|
|
policy.PasswordComplexityPolicyAddedEvent
|
|
}
|
|
|
|
func NewPasswordComplexityPolicyAddedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
minLength uint64,
|
|
hasLowercase,
|
|
hasUppercase,
|
|
hasNumber,
|
|
hasSymbol bool,
|
|
) *PasswordComplexityPolicyAddedEvent {
|
|
return &PasswordComplexityPolicyAddedEvent{
|
|
PasswordComplexityPolicyAddedEvent: *policy.NewPasswordComplexityPolicyAddedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
PasswordComplexityPolicyAddedEventType),
|
|
minLength,
|
|
hasLowercase,
|
|
hasUppercase,
|
|
hasNumber,
|
|
hasSymbol),
|
|
}
|
|
}
|
|
|
|
func PasswordComplexityPolicyAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
|
e, err := policy.PasswordComplexityPolicyAddedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &PasswordComplexityPolicyAddedEvent{PasswordComplexityPolicyAddedEvent: *e.(*policy.PasswordComplexityPolicyAddedEvent)}, nil
|
|
}
|
|
|
|
type PasswordComplexityPolicyChangedEvent struct {
|
|
policy.PasswordComplexityPolicyChangedEvent
|
|
}
|
|
|
|
func NewPasswordComplexityPolicyChangedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
changes []policy.PasswordComplexityPolicyChanges,
|
|
) (*PasswordComplexityPolicyChangedEvent, error) {
|
|
changedEvent, err := policy.NewPasswordComplexityPolicyChangedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
PasswordComplexityPolicyChangedEventType),
|
|
changes,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &PasswordComplexityPolicyChangedEvent{PasswordComplexityPolicyChangedEvent: *changedEvent}, nil
|
|
}
|
|
|
|
func PasswordComplexityPolicyChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
|
e, err := policy.PasswordComplexityPolicyChangedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &PasswordComplexityPolicyChangedEvent{PasswordComplexityPolicyChangedEvent: *e.(*policy.PasswordComplexityPolicyChangedEvent)}, nil
|
|
}
|