fix: features and texts models (#2653)

This commit is contained in:
Livio Amstutz 2021-11-12 09:50:37 +01:00 committed by GitHub
parent 5bc0520adb
commit 7324e776cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 2 deletions

View File

@ -22,7 +22,7 @@ func (wm *CustomLoginTextsReadModel) Reduce() error {
wm.CustomLoginTexts[e.Template+e.Language.String()] = &CustomText{Language: e.Language, Template: e.Template} wm.CustomLoginTexts[e.Template+e.Language.String()] = &CustomText{Language: e.Language, Template: e.Template}
case *policy.CustomTextTemplateRemovedEvent: case *policy.CustomTextTemplateRemovedEvent:
if _, ok := wm.CustomLoginTexts[e.Template+e.Language.String()]; ok { if _, ok := wm.CustomLoginTexts[e.Template+e.Language.String()]; ok {
delete(wm.CustomLoginTexts, e.Template) delete(wm.CustomLoginTexts, e.Template+e.Language.String())
} }
} }
} }

View File

@ -159,7 +159,7 @@ func (wm *CustomMessageTemplatesReadModel) Reduce() error {
} }
case *policy.CustomTextTemplateRemovedEvent: case *policy.CustomTextTemplateRemovedEvent:
if _, ok := wm.CustomMessageTemplate[e.Template+e.Language.String()]; ok { if _, ok := wm.CustomMessageTemplate[e.Template+e.Language.String()]; ok {
delete(wm.CustomMessageTemplate, e.Template) delete(wm.CustomMessageTemplate, e.Template+e.Language.String())
} }
} }
} }

View File

@ -87,6 +87,9 @@ func (wm *FeaturesWriteModel) Reduce() error {
if e.CustomDomain != nil { if e.CustomDomain != nil {
wm.CustomDomain = *e.CustomDomain wm.CustomDomain = *e.CustomDomain
} }
if e.PrivacyPolicy != nil {
wm.PrivacyPolicy = *e.PrivacyPolicy
}
if e.MetadataUser != nil { if e.MetadataUser != nil {
wm.MetadataUser = *e.MetadataUser wm.MetadataUser = *e.MetadataUser
} }

View File

@ -185,9 +185,16 @@ func writeModelToFeatures(wm *FeaturesWriteModel) *domain.Features {
LoginPolicyPasswordless: wm.LoginPolicyPasswordless, LoginPolicyPasswordless: wm.LoginPolicyPasswordless,
LoginPolicyRegistration: wm.LoginPolicyRegistration, LoginPolicyRegistration: wm.LoginPolicyRegistration,
LoginPolicyUsernameLogin: wm.LoginPolicyUsernameLogin, LoginPolicyUsernameLogin: wm.LoginPolicyUsernameLogin,
LoginPolicyPasswordReset: wm.LoginPolicyPasswordReset,
PasswordComplexityPolicy: wm.PasswordComplexityPolicy, PasswordComplexityPolicy: wm.PasswordComplexityPolicy,
LabelPolicyPrivateLabel: wm.LabelPolicyPrivateLabel, LabelPolicyPrivateLabel: wm.LabelPolicyPrivateLabel,
LabelPolicyWatermark: wm.LabelPolicyWatermark, LabelPolicyWatermark: wm.LabelPolicyWatermark,
CustomDomain: wm.CustomDomain, CustomDomain: wm.CustomDomain,
PrivacyPolicy: wm.PrivacyPolicy,
MetadataUser: wm.MetadataUser,
CustomTextMessage: wm.CustomTextMessage,
CustomTextLogin: wm.CustomTextLogin,
LockoutPolicy: wm.LockoutPolicy,
Actions: wm.Actions,
} }
} }

View File

@ -45,6 +45,7 @@ func (c *Commands) setDefaultFeatures(ctx context.Context, existingFeatures *IAM
features.LoginPolicyPasswordless, features.LoginPolicyPasswordless,
features.LoginPolicyRegistration, features.LoginPolicyRegistration,
features.LoginPolicyUsernameLogin, features.LoginPolicyUsernameLogin,
features.LoginPolicyPasswordReset,
features.PasswordComplexityPolicy, features.PasswordComplexityPolicy,
features.LabelPolicyPrivateLabel, features.LabelPolicyPrivateLabel,
features.LabelPolicyWatermark, features.LabelPolicyWatermark,

View File

@ -63,6 +63,7 @@ func (wm *IAMFeaturesWriteModel) NewSetEvent(
loginPolicyPasswordless, loginPolicyPasswordless,
loginPolicyRegistration, loginPolicyRegistration,
loginPolicyUsernameLogin, loginPolicyUsernameLogin,
loginPolicyPasswordReset,
passwordComplexityPolicy, passwordComplexityPolicy,
labelPolicyPrivateLabel, labelPolicyPrivateLabel,
labelPolicyWatermark, labelPolicyWatermark,
@ -107,6 +108,9 @@ func (wm *IAMFeaturesWriteModel) NewSetEvent(
if wm.LoginPolicyUsernameLogin != loginPolicyUsernameLogin { if wm.LoginPolicyUsernameLogin != loginPolicyUsernameLogin {
changes = append(changes, features.ChangeLoginPolicyUsernameLogin(loginPolicyUsernameLogin)) changes = append(changes, features.ChangeLoginPolicyUsernameLogin(loginPolicyUsernameLogin))
} }
if wm.LoginPolicyPasswordReset != loginPolicyPasswordReset {
changes = append(changes, features.ChangeLoginPolicyPasswordReset(loginPolicyPasswordReset))
}
if wm.PasswordComplexityPolicy != passwordComplexityPolicy { if wm.PasswordComplexityPolicy != passwordComplexityPolicy {
changes = append(changes, features.ChangePasswordComplexityPolicy(passwordComplexityPolicy)) changes = append(changes, features.ChangePasswordComplexityPolicy(passwordComplexityPolicy))
} }