mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-06 02:48:50 +00:00
fix: move v2 pkgs (#1331)
* fix: move eventstore pkgs * fix: move eventstore pkgs * fix: remove v2 view * fix: remove v2 view
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package query
|
||||
|
||||
import (
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
"github.com/caos/zitadel/internal/eventstore"
|
||||
"github.com/caos/zitadel/internal/repository/policy"
|
||||
)
|
||||
|
||||
type LoginPolicyReadModel struct {
|
||||
eventstore.ReadModel
|
||||
|
||||
AllowUserNamePassword bool
|
||||
AllowRegister bool
|
||||
AllowExternalIDP bool
|
||||
ForceMFA bool
|
||||
PasswordlessType domain.PasswordlessType
|
||||
IsActive bool
|
||||
}
|
||||
|
||||
func (rm *LoginPolicyReadModel) Reduce() error {
|
||||
for _, event := range rm.Events {
|
||||
switch e := event.(type) {
|
||||
case *policy.LoginPolicyAddedEvent:
|
||||
rm.AllowUserNamePassword = e.AllowUserNamePassword
|
||||
rm.AllowExternalIDP = e.AllowExternalIDP
|
||||
rm.AllowRegister = e.AllowRegister
|
||||
rm.ForceMFA = e.ForceMFA
|
||||
rm.PasswordlessType = e.PasswordlessType
|
||||
rm.IsActive = true
|
||||
case *policy.LoginPolicyChangedEvent:
|
||||
if e.AllowUserNamePassword != nil {
|
||||
rm.AllowUserNamePassword = *e.AllowUserNamePassword
|
||||
}
|
||||
if e.AllowExternalIDP != nil {
|
||||
rm.AllowExternalIDP = *e.AllowExternalIDP
|
||||
}
|
||||
if e.AllowRegister != nil {
|
||||
rm.AllowRegister = *e.AllowRegister
|
||||
}
|
||||
if e.ForceMFA != nil {
|
||||
rm.ForceMFA = *e.ForceMFA
|
||||
}
|
||||
if e.PasswordlessType != nil {
|
||||
rm.PasswordlessType = *e.PasswordlessType
|
||||
}
|
||||
case *policy.LoginPolicyRemovedEvent:
|
||||
rm.IsActive = false
|
||||
}
|
||||
}
|
||||
return rm.ReadModel.Reduce()
|
||||
}
|
||||
Reference in New Issue
Block a user