Pass username to template
All checks were successful
Build and push Probo image on the registry / login (push) Successful in 2m52s

This commit is contained in:
andrea 2025-05-06 18:15:57 +02:00
commit 647d694e91

View file

@ -15,6 +15,7 @@ var ExamsHandler = func(h *template.Handler, w http.ResponseWriter, r *http.Requ
}
claims := token.Claims.(jwt.MapClaims)
username := claims["username"].(string)
isAdmin := claims["is_admin"].(bool)
if !isAdmin {
@ -31,8 +32,9 @@ var ExamsHandler = func(h *template.Handler, w http.ResponseWriter, r *http.Requ
log.Info("Showing exams", "session", session)
err = h.WithData(map[string]interface{}{
"Session": session,
"Exams": exams,
"Username": username,
"Session": session,
"Exams": exams,
}).ExecuteTemplate(w)
if err != nil {
panic(err)