From 087ef8d31c134a32cbbd06f4fa8802b5df9ba3b6 Mon Sep 17 00:00:00 2001 From: Fabi <38692350+fgerschwiler@users.noreply.github.com> Date: Thu, 20 Jan 2022 14:18:49 +0100 Subject: [PATCH] fix: return isDefault on login texts (#3076) * fix: add is disabled to login texts * fix: fix aggregate id --- docs/docs/apis/proto/text.md | 1 + internal/api/grpc/text/custom_text.go | 1 + internal/domain/custom_login_text.go | 7 ++++--- internal/query/custom_text.go | 10 +++++++++- proto/zitadel/text.proto | 1 + 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/docs/apis/proto/text.md b/docs/docs/apis/proto/text.md index b5a9012cf..dabf6946f 100644 --- a/docs/docs/apis/proto/text.md +++ b/docs/docs/apis/proto/text.md @@ -278,6 +278,7 @@ title: zitadel/text.proto | passwordless_registration_text | PasswordlessRegistrationScreenText | - | | | passwordless_registration_done_text | PasswordlessRegistrationDoneScreenText | - | | | external_registration_user_overview_text | ExternalRegistrationUserOverviewScreenText | - | | +| is_default | bool | - | | diff --git a/internal/api/grpc/text/custom_text.go b/internal/api/grpc/text/custom_text.go index 917cbb193..f9045112d 100644 --- a/internal/api/grpc/text/custom_text.go +++ b/internal/api/grpc/text/custom_text.go @@ -34,6 +34,7 @@ func CustomLoginTextToPb(text *domain.CustomLoginText) *text_pb.LoginCustomText text.ChangeDate, text.AggregateID, ), + IsDefault: text.IsDefault, SelectAccountText: SelectAccountScreenToPb(text.SelectAccount), LoginText: LoginScreenTextToPb(text.Login), PasswordText: PasswordScreenTextToPb(text.Password), diff --git a/internal/domain/custom_login_text.go b/internal/domain/custom_login_text.go index f9876a2c9..386eaf22b 100644 --- a/internal/domain/custom_login_text.go +++ b/internal/domain/custom_login_text.go @@ -300,9 +300,10 @@ const ( type CustomLoginText struct { models.ObjectRoot - State PolicyState - Default bool - Language language.Tag + State PolicyState + Default bool + Language language.Tag + IsDefault bool SelectAccount SelectAccountScreenText Login LoginScreenText diff --git a/internal/query/custom_text.go b/internal/query/custom_text.go index 76684d29d..1fe8e4f70 100644 --- a/internal/query/custom_text.go +++ b/internal/query/custom_text.go @@ -131,6 +131,8 @@ func (q *Queries) GetDefaultLoginTexts(ctx context.Context, lang string) (*domai if err := yaml.Unmarshal(contents, loginText); err != nil { return nil, errors.ThrowInternal(err, "TEXT-M0p4s", "Errors.TranslationFile.ReadError") } + loginText.IsDefault = true + loginText.AggregateID = domain.IAMID return loginText, nil } @@ -139,7 +141,7 @@ func (q *Queries) GetCustomLoginTexts(ctx context.Context, aggregateID, lang str if err != nil { return nil, err } - return CustomTextsToLoginDomain(domain.IAMID, lang, texts), err + return CustomTextsToLoginDomain(aggregateID, lang, texts), err } func (q *Queries) IAMLoginTexts(ctx context.Context, lang string) (*domain.CustomLoginText, error) { @@ -171,6 +173,8 @@ func (q *Queries) IAMLoginTexts(ctx context.Context, lang string) (*domain.Custo if err := json.Unmarshal(jsonbody, &loginText); err != nil { return nil, errors.ThrowInternal(err, "QUERY-m93Jf", "Errors.TranslationFile.MergeError") } + loginText.AggregateID = domain.IAMID + loginText.IsDefault = true return loginText, nil } @@ -272,6 +276,10 @@ func CustomTextsToLoginDomain(aggregateID, lang string, texts *CustomTexts) *dom }, Language: langTag, } + if len(texts.CustomTexts) == 0 { + result.AggregateID = domain.IAMID + result.IsDefault = true + } for _, text := range texts.CustomTexts { if text.CreationDate.Before(result.CreationDate) { result.CreationDate = text.CreationDate diff --git a/proto/zitadel/text.proto b/proto/zitadel/text.proto index ed01b6efa..a4d9c15c7 100644 --- a/proto/zitadel/text.proto +++ b/proto/zitadel/text.proto @@ -84,6 +84,7 @@ message LoginCustomText { PasswordlessRegistrationScreenText passwordless_registration_text = 33; PasswordlessRegistrationDoneScreenText passwordless_registration_done_text = 34; ExternalRegistrationUserOverviewScreenText external_registration_user_overview_text = 35; + bool is_default = 36; } message SelectAccountScreenText {