fix: return isDefault on login texts (#3076)

* fix: add is disabled to login texts

* fix: fix aggregate id
This commit is contained in:
Fabi 2022-01-20 14:18:49 +01:00 committed by GitHub
parent 5c6df06a7c
commit 087ef8d31c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 4 deletions

View File

@ -278,6 +278,7 @@ title: zitadel/text.proto
| passwordless_registration_text | PasswordlessRegistrationScreenText | - | | | passwordless_registration_text | PasswordlessRegistrationScreenText | - | |
| passwordless_registration_done_text | PasswordlessRegistrationDoneScreenText | - | | | passwordless_registration_done_text | PasswordlessRegistrationDoneScreenText | - | |
| external_registration_user_overview_text | ExternalRegistrationUserOverviewScreenText | - | | | external_registration_user_overview_text | ExternalRegistrationUserOverviewScreenText | - | |
| is_default | bool | - | |

View File

@ -34,6 +34,7 @@ func CustomLoginTextToPb(text *domain.CustomLoginText) *text_pb.LoginCustomText
text.ChangeDate, text.ChangeDate,
text.AggregateID, text.AggregateID,
), ),
IsDefault: text.IsDefault,
SelectAccountText: SelectAccountScreenToPb(text.SelectAccount), SelectAccountText: SelectAccountScreenToPb(text.SelectAccount),
LoginText: LoginScreenTextToPb(text.Login), LoginText: LoginScreenTextToPb(text.Login),
PasswordText: PasswordScreenTextToPb(text.Password), PasswordText: PasswordScreenTextToPb(text.Password),

View File

@ -300,9 +300,10 @@ const (
type CustomLoginText struct { type CustomLoginText struct {
models.ObjectRoot models.ObjectRoot
State PolicyState State PolicyState
Default bool Default bool
Language language.Tag Language language.Tag
IsDefault bool
SelectAccount SelectAccountScreenText SelectAccount SelectAccountScreenText
Login LoginScreenText Login LoginScreenText

View File

@ -131,6 +131,8 @@ func (q *Queries) GetDefaultLoginTexts(ctx context.Context, lang string) (*domai
if err := yaml.Unmarshal(contents, loginText); err != nil { if err := yaml.Unmarshal(contents, loginText); err != nil {
return nil, errors.ThrowInternal(err, "TEXT-M0p4s", "Errors.TranslationFile.ReadError") return nil, errors.ThrowInternal(err, "TEXT-M0p4s", "Errors.TranslationFile.ReadError")
} }
loginText.IsDefault = true
loginText.AggregateID = domain.IAMID
return loginText, nil return loginText, nil
} }
@ -139,7 +141,7 @@ func (q *Queries) GetCustomLoginTexts(ctx context.Context, aggregateID, lang str
if err != nil { if err != nil {
return nil, err 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) { 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 { if err := json.Unmarshal(jsonbody, &loginText); err != nil {
return nil, errors.ThrowInternal(err, "QUERY-m93Jf", "Errors.TranslationFile.MergeError") return nil, errors.ThrowInternal(err, "QUERY-m93Jf", "Errors.TranslationFile.MergeError")
} }
loginText.AggregateID = domain.IAMID
loginText.IsDefault = true
return loginText, nil return loginText, nil
} }
@ -272,6 +276,10 @@ func CustomTextsToLoginDomain(aggregateID, lang string, texts *CustomTexts) *dom
}, },
Language: langTag, Language: langTag,
} }
if len(texts.CustomTexts) == 0 {
result.AggregateID = domain.IAMID
result.IsDefault = true
}
for _, text := range texts.CustomTexts { for _, text := range texts.CustomTexts {
if text.CreationDate.Before(result.CreationDate) { if text.CreationDate.Before(result.CreationDate) {
result.CreationDate = text.CreationDate result.CreationDate = text.CreationDate

View File

@ -84,6 +84,7 @@ message LoginCustomText {
PasswordlessRegistrationScreenText passwordless_registration_text = 33; PasswordlessRegistrationScreenText passwordless_registration_text = 33;
PasswordlessRegistrationDoneScreenText passwordless_registration_done_text = 34; PasswordlessRegistrationDoneScreenText passwordless_registration_done_text = 34;
ExternalRegistrationUserOverviewScreenText external_registration_user_overview_text = 35; ExternalRegistrationUserOverviewScreenText external_registration_user_overview_text = 35;
bool is_default = 36;
} }
message SelectAccountScreenText { message SelectAccountScreenText {