mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-18 05:47:32 +00:00
6863aeac59
* fix: custom domain * fix: custom domain * fix: custom domain * fix: custom domain feature in proto * fix: remove custom domains on feature downgrade * fix test * fix: custom domain feature in proto * ensure tests work Co-authored-by: fabi <fabienne.gerschwiler@gmail.com>
79 lines
2.0 KiB
Go
79 lines
2.0 KiB
Go
package command
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/caos/zitadel/internal/domain"
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
"github.com/caos/zitadel/internal/repository/features"
|
|
)
|
|
|
|
type FeaturesWriteModel struct {
|
|
eventstore.WriteModel
|
|
|
|
TierName string
|
|
TierDescription string
|
|
State domain.FeaturesState
|
|
StateDescription string
|
|
AuditLogRetention time.Duration
|
|
LoginPolicyFactors bool
|
|
LoginPolicyIDP bool
|
|
LoginPolicyPasswordless bool
|
|
LoginPolicyRegistration bool
|
|
LoginPolicyUsernameLogin bool
|
|
PasswordComplexityPolicy bool
|
|
LabelPolicy bool
|
|
CustomDomain bool
|
|
}
|
|
|
|
func (wm *FeaturesWriteModel) Reduce() error {
|
|
for _, event := range wm.Events {
|
|
switch e := event.(type) {
|
|
case *features.FeaturesSetEvent:
|
|
if e.TierName != nil {
|
|
wm.TierName = *e.TierName
|
|
}
|
|
if e.TierDescription != nil {
|
|
wm.TierDescription = *e.TierDescription
|
|
}
|
|
wm.State = domain.FeaturesStateActive
|
|
if e.State != nil {
|
|
wm.State = *e.State
|
|
}
|
|
if e.StateDescription != nil {
|
|
wm.StateDescription = *e.StateDescription
|
|
}
|
|
if e.AuditLogRetention != nil {
|
|
wm.AuditLogRetention = *e.AuditLogRetention
|
|
}
|
|
if e.LoginPolicyFactors != nil {
|
|
wm.LoginPolicyFactors = *e.LoginPolicyFactors
|
|
}
|
|
if e.LoginPolicyIDP != nil {
|
|
wm.LoginPolicyIDP = *e.LoginPolicyIDP
|
|
}
|
|
if e.LoginPolicyPasswordless != nil {
|
|
wm.LoginPolicyPasswordless = *e.LoginPolicyPasswordless
|
|
}
|
|
if e.LoginPolicyRegistration != nil {
|
|
wm.LoginPolicyRegistration = *e.LoginPolicyRegistration
|
|
}
|
|
if e.LoginPolicyUsernameLogin != nil {
|
|
wm.LoginPolicyUsernameLogin = *e.LoginPolicyUsernameLogin
|
|
}
|
|
if e.PasswordComplexityPolicy != nil {
|
|
wm.PasswordComplexityPolicy = *e.PasswordComplexityPolicy
|
|
}
|
|
if e.LabelPolicy != nil {
|
|
wm.LabelPolicy = *e.LabelPolicy
|
|
}
|
|
if e.CustomDomain != nil {
|
|
wm.CustomDomain = *e.CustomDomain
|
|
}
|
|
case *features.FeaturesRemovedEvent:
|
|
wm.State = domain.FeaturesStateRemoved
|
|
}
|
|
}
|
|
return wm.WriteModel.Reduce()
|
|
}
|