mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-12 11:43:40 +00:00
fix: read custom texts for pages called directly form mail link (#4255)
* fix: read custom texts for pages called directly form mail link * log errors
This commit is contained in:
parent
e1a981928c
commit
64f589c435
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user