mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
improve some functions
This commit is contained in:
parent
f5af4461ad
commit
b753e06f0b
@ -98,12 +98,12 @@ func (t *Translator) localizer(langs ...string) *i18n.Localizer {
|
||||
|
||||
func (t *Translator) langsFromRequest(r *http.Request) []string {
|
||||
langs := make([]string, 0)
|
||||
if r != nil {
|
||||
lang, err := t.cookieHandler.GetCookieValue(r, t.cookieName)
|
||||
if err == nil {
|
||||
langs = append(langs, lang)
|
||||
}
|
||||
langs = append(langs, r.Header.Get(api.AcceptLanguage))
|
||||
if r == nil {
|
||||
return langs
|
||||
}
|
||||
return langs
|
||||
lang, err := t.cookieHandler.GetCookieValue(r, t.cookieName)
|
||||
if err == nil {
|
||||
langs = append(langs, lang)
|
||||
}
|
||||
return append(langs, r.Header.Get(api.AcceptLanguage))
|
||||
}
|
||||
|
@ -31,9 +31,8 @@ func NewRenderer(templatesDir string, tmplMapping map[string]string, funcs map[s
|
||||
|
||||
func (r *Renderer) RenderTemplate(w http.ResponseWriter, req *http.Request, tmpl *template.Template, data interface{}, reqFuncs map[string]interface{}) {
|
||||
reqFuncs = r.registerTranslateFn(req, reqFuncs)
|
||||
if err := tmpl.Funcs(reqFuncs).Execute(w, data); err != nil {
|
||||
logging.Log("HTML-lF8F6w").WithError(err).WithField("template", tmpl.Name).Error("error rendering template")
|
||||
}
|
||||
err := tmpl.Funcs(reqFuncs).Execute(w, data)
|
||||
logging.LogWithFields("HTML-lF8F6w", "template", tmpl.Name).OnError(err).Error("error rendering template")
|
||||
}
|
||||
|
||||
func (r *Renderer) Localize(id string, args map[string]interface{}) string {
|
||||
|
@ -85,10 +85,7 @@ func (c *CookieHandler) GetEncryptedCookieValue(r *http.Request, name string, va
|
||||
if c.securecookie == nil {
|
||||
return errors.ThrowInternal(nil, "HTTP-X6XpnL", "securecookie not configured")
|
||||
}
|
||||
if err := c.securecookie.Decode(name, cookie.Value, value); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return c.securecookie.Decode(name, cookie.Value, value)
|
||||
}
|
||||
|
||||
func (c *CookieHandler) SetCookie(w http.ResponseWriter, name string, value string) {
|
||||
|
Loading…
Reference in New Issue
Block a user