mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-18 05:47:32 +00:00
d8e42744b4
* fix: move eventstore pkgs * fix: move eventstore pkgs * fix: remove v2 view * fix: remove v2 view
47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package query
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
"github.com/caos/zitadel/internal/repository/policy"
|
|
)
|
|
|
|
type PasswordComplexityPolicyReadModel struct {
|
|
eventstore.ReadModel
|
|
|
|
MinLength uint64
|
|
HasLowercase bool
|
|
HasUpperCase bool
|
|
HasNumber bool
|
|
HasSymbol bool
|
|
}
|
|
|
|
func (rm *PasswordComplexityPolicyReadModel) Reduce() error {
|
|
for _, event := range rm.Events {
|
|
switch e := event.(type) {
|
|
case *policy.PasswordComplexityPolicyAddedEvent:
|
|
rm.MinLength = e.MinLength
|
|
rm.HasLowercase = e.HasLowercase
|
|
rm.HasUpperCase = e.HasUppercase
|
|
rm.HasNumber = e.HasNumber
|
|
rm.HasSymbol = e.HasSymbol
|
|
case *policy.PasswordComplexityPolicyChangedEvent:
|
|
if e.MinLength != nil {
|
|
rm.MinLength = *e.MinLength
|
|
}
|
|
if e.HasLowercase != nil {
|
|
rm.HasLowercase = *e.HasLowercase
|
|
}
|
|
if e.HasUppercase != nil {
|
|
rm.HasUpperCase = *e.HasUppercase
|
|
}
|
|
if e.HasNumber != nil {
|
|
rm.HasNumber = *e.HasNumber
|
|
}
|
|
if e.HasSymbol != nil {
|
|
rm.HasSymbol = *e.HasSymbol
|
|
}
|
|
}
|
|
}
|
|
return rm.ReadModel.Reduce()
|
|
}
|