diff --git a/internal/api/ui/login/init_password_handler.go b/internal/api/ui/login/init_password_handler.go index 0b88afd224..0555214fd1 100644 --- a/internal/api/ui/login/init_password_handler.go +++ b/internal/api/ui/login/init_password_handler.go @@ -148,6 +148,12 @@ func (l *Login) renderInitPassword(w http.ResponseWriter, r *http.Request, authR } } translator := l.getTranslator(r.Context(), authReq) + if authReq == nil { + user, err := l.query.GetUserByID(r.Context(), false, userID) + if err == nil { + l.customTexts(r.Context(), translator, user.ResourceOwner) + } + } l.renderer.RenderTemplate(w, r, translator, l.renderer.Templates[tmplInitPassword], data, nil) } diff --git a/internal/api/ui/login/init_user_handler.go b/internal/api/ui/login/init_user_handler.go index b29ac612df..b90e1070d9 100644 --- a/internal/api/ui/login/init_user_handler.go +++ b/internal/api/ui/login/init_user_handler.go @@ -6,7 +6,6 @@ import ( "strconv" "github.com/zitadel/zitadel/internal/domain" - caos_errs "github.com/zitadel/zitadel/internal/errors" ) @@ -138,6 +137,12 @@ func (l *Login) renderInitUser(w http.ResponseWriter, r *http.Request, authReq * } } translator := l.getTranslator(r.Context(), authReq) + if authReq == nil { + user, err := l.query.GetUserByID(r.Context(), false, userID) + if err == nil { + l.customTexts(r.Context(), translator, user.ResourceOwner) + } + } l.renderer.RenderTemplate(w, r, translator, l.renderer.Templates[tmplInitUser], data, nil) } diff --git a/internal/api/ui/login/mail_verify_handler.go b/internal/api/ui/login/mail_verify_handler.go index 741d8ec288..36449fdfbd 100644 --- a/internal/api/ui/login/mail_verify_handler.go +++ b/internal/api/ui/login/mail_verify_handler.go @@ -98,6 +98,12 @@ func (l *Login) renderMailVerification(w http.ResponseWriter, r *http.Request, a profileData: l.getProfileData(authReq), } translator := l.getTranslator(r.Context(), authReq) + if authReq == nil { + user, err := l.query.GetUserByID(r.Context(), false, userID) + if err == nil { + l.customTexts(r.Context(), translator, user.ResourceOwner) + } + } l.renderer.RenderTemplate(w, r, translator, l.renderer.Templates[tmplMailVerification], data, nil) } diff --git a/internal/api/ui/login/renderer.go b/internal/api/ui/login/renderer.go index c083a4f479..21f5ae7193 100644 --- a/internal/api/ui/login/renderer.go +++ b/internal/api/ui/login/renderer.go @@ -19,6 +19,7 @@ import ( caos_errs "github.com/zitadel/zitadel/internal/errors" "github.com/zitadel/zitadel/internal/i18n" "github.com/zitadel/zitadel/internal/notification/templates" + "github.com/zitadel/zitadel/internal/query" "github.com/zitadel/zitadel/internal/renderer" "github.com/zitadel/zitadel/internal/static" ) @@ -519,10 +520,29 @@ func (l *Login) addLoginTranslations(translator *i18n.Translator, customTexts [] Text: text.Text, } err := l.renderer.AddMessages(translator, text.Language, msg) - logging.Log("HANDLE-GD3g2").OnError(err).Warn("could no add message to translator") + logging.OnError(err).Warn("could no add message to translator") } } +func (l *Login) customTexts(ctx context.Context, translator *i18n.Translator, orgID string) { + instanceID := authz.GetInstance(ctx).InstanceID() + instanceTexts, err := l.query.CustomTextListByTemplate(ctx, instanceID, domain.LoginCustomText) + if err != nil { + logging.WithFields("instanceID", instanceID).Warn("unable to load custom texts for instance") + return + } + l.addLoginTranslations(translator, query.CustomTextsToDomain(instanceTexts)) + if orgID == "" { + return + } + orgTexts, err := l.query.CustomTextListByTemplate(ctx, orgID, domain.LoginCustomText) + if err != nil { + logging.WithFields("instanceID", instanceID, "org", orgID).Warn("unable to load custom texts for org") + return + } + l.addLoginTranslations(translator, query.CustomTextsToDomain(orgTexts)) +} + func getRequestID(authReq *domain.AuthRequest, r *http.Request) string { if authReq != nil { return authReq.ID