zitadel/internal/repository/iam/policy_password_complexity.go
Fabi d8e42744b4
fix: move v2 pkgs (#1331)
* fix: move eventstore pkgs

* fix: move eventstore pkgs

* fix: remove v2 view

* fix: remove v2 view
2021-02-23 15:13:04 +01:00

82 lines
2.3 KiB
Go

package iam
import (
"context"
"github.com/caos/zitadel/internal/eventstore"
"github.com/caos/zitadel/internal/eventstore/repository"
"github.com/caos/zitadel/internal/repository/policy"
)
const (
PasswordComplexityPolicyAddedEventType = iamEventTypePrefix + policy.PasswordComplexityPolicyAddedEventType
PasswordComplexityPolicyChangedEventType = iamEventTypePrefix + 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.EventReader, 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.EventReader, error) {
e, err := policy.PasswordComplexityPolicyChangedEventMapper(event)
if err != nil {
return nil, err
}
return &PasswordComplexityPolicyChangedEvent{PasswordComplexityPolicyChangedEvent: *e.(*policy.PasswordComplexityPolicyChangedEvent)}, nil
}