1
0
mirror of https://github.com/zitadel/zitadel.git synced 2024-12-14 11:58:02 +00:00
zitadel/internal/query/policy_password_complexity_model.go
Fabi d8e42744b4
fix: move v2 pkgs ()
* fix: move eventstore pkgs

* fix: move eventstore pkgs

* fix: remove v2 view

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

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()
}