Display user name only if claims are not nil

This commit is contained in:
Andrea Fazzi 2019-11-18 10:51:44 +01:00
parent 12f2a7a1d5
commit 945a2a29dd

View file

@ -247,7 +247,9 @@ func (rend *HTMLRenderer) Render(w http.ResponseWriter, r *http.Request, data in
rend.writeError(w, r, &htmlTemplateData{err, nil})
}
if r.Context().Value("user") != nil {
log.Println("Current user is", r.Context().Value("user").(*jwt.Token).Claims.(jwt.MapClaims)["name"])
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
err := t.ExecuteTemplate(w, options[0]["tpl_layout"][0], &htmlTemplateData{data, options[0]})