fix(logintexts): fix several custom text attributes for get and set (#4733)

* fix(logintexts): fix several custom text attributes for get and set

* fix(logintexts): fix externalUserNotFound attribute for json unmarshalling and reduce for customTexts

* fix: correct imports for linting
This commit is contained in:
Stefan Benz
2022-12-01 12:31:46 +00:00
committed by GitHub
parent 9fbd1034c2
commit 9626897834
10 changed files with 88 additions and 32 deletions

View File

@@ -998,39 +998,39 @@ func (c *Commands) createLinkingUserEvents(ctx context.Context, agg *eventstore.
func (c *Commands) createExternalUserNotFoundEvents(ctx context.Context, agg *eventstore.Aggregate, existingText *CustomLoginTextReadModel, text *domain.CustomLoginText, defaultText bool) []eventstore.Command {
events := make([]eventstore.Command, 0)
event := c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundTitle, existingText.ExternalUserNotFoundTitle, text.ExternalNotFoundOption.Title, text.Language, defaultText)
event := c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundTitle, existingText.ExternalUserNotFoundTitle, text.ExternalNotFound.Title, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundDescription, existingText.ExternalUserNotFoundDescription, text.ExternalNotFoundOption.Description, text.Language, defaultText)
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundDescription, existingText.ExternalUserNotFoundDescription, text.ExternalNotFound.Description, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundLinkButtonText, existingText.ExternalUserNotFoundLinkButtonText, text.ExternalNotFoundOption.LinkButtonText, text.Language, defaultText)
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundLinkButtonText, existingText.ExternalUserNotFoundLinkButtonText, text.ExternalNotFound.LinkButtonText, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundAutoRegisterButtonText, existingText.ExternalUserNotFoundAutoRegisterButtonText, text.ExternalNotFoundOption.AutoRegisterButtonText, text.Language, defaultText)
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundAutoRegisterButtonText, existingText.ExternalUserNotFoundAutoRegisterButtonText, text.ExternalNotFound.AutoRegisterButtonText, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundTOSAndPrivacyLabel, existingText.ExternalUserNotFoundTOSAndPrivacyLabel, text.ExternalNotFoundOption.TOSAndPrivacyLabel, text.Language, defaultText)
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundTOSAndPrivacyLabel, existingText.ExternalUserNotFoundTOSAndPrivacyLabel, text.ExternalNotFound.TOSAndPrivacyLabel, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundTOSConfirm, existingText.ExternalUserNotFoundTOSConfirm, text.ExternalNotFoundOption.TOSConfirm, text.Language, defaultText)
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundTOSConfirm, existingText.ExternalUserNotFoundTOSConfirm, text.ExternalNotFound.TOSConfirm, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundTOSLinkText, existingText.ExternalUserNotFoundTOSLinkText, text.ExternalNotFoundOption.TOSLinkText, text.Language, defaultText)
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundTOSLinkText, existingText.ExternalUserNotFoundTOSLinkText, text.ExternalNotFound.TOSLinkText, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundTOSConfirmAnd, existingText.ExternalUserNotFoundTOSConfirmAnd, text.ExternalNotFoundOption.TOSConfirmAnd, text.Language, defaultText)
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundTOSConfirmAnd, existingText.ExternalUserNotFoundTOSConfirmAnd, text.ExternalNotFound.TOSConfirmAnd, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundPrivacyLinkText, existingText.ExternalUserNotFoundPrivacyLinkText, text.ExternalNotFoundOption.PrivacyLinkText, text.Language, defaultText)
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundPrivacyLinkText, existingText.ExternalUserNotFoundPrivacyLinkText, text.ExternalNotFound.PrivacyLinkText, text.Language, defaultText)
if event != nil {
events = append(events, event)
}

View File

@@ -54,7 +54,7 @@ func (wm *CustomMessageTextReadModel) Reduce() error {
}
wm.State = domain.PolicyStateActive
case *policy.CustomTextRemovedEvent:
if e.Key != wm.MessageTextType || wm.Language != e.Language {
if e.Template != wm.MessageTextType || wm.Language != e.Language {
continue
}
if e.Key == domain.MessageSubject {
@@ -79,7 +79,7 @@ func (wm *CustomMessageTextReadModel) Reduce() error {
wm.FooterText = ""
}
case *policy.CustomTextTemplateRemovedEvent:
if wm.Language != e.Language {
if e.Template != wm.MessageTextType || wm.Language != e.Language {
continue
}
wm.Subject = ""

View File

@@ -5,9 +5,9 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/zitadel/zitadel/internal/api/authz"
"golang.org/x/text/language"
"github.com/zitadel/zitadel/internal/api/authz"
"github.com/zitadel/zitadel/internal/domain"
caos_errs "github.com/zitadel/zitadel/internal/errors"
"github.com/zitadel/zitadel/internal/eventstore"
@@ -1631,7 +1631,7 @@ func TestCommandSide_SetCustomIAMLoginText(t *testing.T) {
CancelButtonText: "CancelButtonText",
NextButtonText: "NextButtonText",
},
ExternalNotFoundOption: domain.ExternalUserNotFoundScreenText{
ExternalNotFound: domain.ExternalUserNotFoundScreenText{
Title: "Title",
Description: "Description",
LinkButtonText: "LinkButtonText",
@@ -4329,7 +4329,7 @@ func TestCommandSide_SetCustomIAMLoginText(t *testing.T) {
ExternalRegistrationUserOverview: domain.ExternalRegistrationUserOverviewScreenText{},
RegistrationOrg: domain.RegistrationOrgScreenText{},
LinkingUsersDone: domain.LinkingUserDoneScreenText{},
ExternalNotFoundOption: domain.ExternalUserNotFoundScreenText{},
ExternalNotFound: domain.ExternalUserNotFoundScreenText{},
LoginSuccess: domain.SuccessLoginScreenText{},
LogoutDone: domain.LogoutDoneScreenText{},
Footer: domain.FooterText{},
@@ -8543,7 +8543,7 @@ func TestCommandSide_SetCustomIAMLoginText(t *testing.T) {
CancelButtonText: "CancelButtonText",
NextButtonText: "NextButtonText",
},
ExternalNotFoundOption: domain.ExternalUserNotFoundScreenText{
ExternalNotFound: domain.ExternalUserNotFoundScreenText{
Title: "Title",
Description: "Description",
LinkButtonText: "LinkButtonText",

View File

@@ -1429,7 +1429,7 @@ func TestCommandSide_SetCustomOrgLoginText(t *testing.T) {
CancelButtonText: "CancelButtonText",
NextButtonText: "NextButtonText",
},
ExternalNotFoundOption: domain.ExternalUserNotFoundScreenText{
ExternalNotFound: domain.ExternalUserNotFoundScreenText{
Title: "Title",
Description: "Description",
LinkButtonText: "LinkButtonText",
@@ -3692,7 +3692,7 @@ func TestCommandSide_SetCustomOrgLoginText(t *testing.T) {
RegistrationUser: domain.RegistrationUserScreenText{},
RegistrationOrg: domain.RegistrationOrgScreenText{},
LinkingUsersDone: domain.LinkingUserDoneScreenText{},
ExternalNotFoundOption: domain.ExternalUserNotFoundScreenText{},
ExternalNotFound: domain.ExternalUserNotFoundScreenText{},
LoginSuccess: domain.SuccessLoginScreenText{},
LogoutDone: domain.LogoutDoneScreenText{},
Footer: domain.FooterText{},
@@ -7251,7 +7251,7 @@ func TestCommandSide_SetCustomOrgLoginText(t *testing.T) {
CancelButtonText: "CancelButtonText",
NextButtonText: "NextButtonText",
},
ExternalNotFoundOption: domain.ExternalUserNotFoundScreenText{
ExternalNotFound: domain.ExternalUserNotFoundScreenText{
Title: "Title",
Description: "Description",
LinkButtonText: "LinkButtonText",