diff --git a/internal/handlers/handler.go b/internal/handlers/handler.go index 295f9db..377edff 100644 --- a/internal/handlers/handler.go +++ b/internal/handlers/handler.go @@ -49,7 +49,6 @@ func (h *Handler) HomeHandler(w http.ResponseWriter, r *http.Request) { session, bump, err := h.auth.ValidateSessionToken(r.Context(), cookie.Value) if err != nil { - log.Print(err.Error()) http.Error(w, "Internal Server Error", http.StatusInternalServerError) return } @@ -63,6 +62,13 @@ func (h *Handler) HomeHandler(w http.ResponseWriter, r *http.Request) { http.SetCookie(w, auth.NewSessionCookie(cookie.Value, false)) } + user, err := h.users.FindByID(r.Context(), session.UserID) + + if err != nil { + http.Error(w, "Internal Server Error", http.StatusInternalServerError) + return + } + files := []string{ "./ui/html/base.tmpl", "./ui/html/pages/index.tmpl", @@ -75,7 +81,7 @@ func (h *Handler) HomeHandler(w http.ResponseWriter, r *http.Request) { return } - err = ts.ExecuteTemplate(w, "base", nil) + err = ts.ExecuteTemplate(w, "base", user.Username) if err != nil { log.Print(err.Error()) http.Error(w, "Internal Server Error", http.StatusInternalServerError) diff --git a/ui/html/base.tmpl b/ui/html/base.tmpl index 28899de..f4a70a1 100644 --- a/ui/html/base.tmpl +++ b/ui/html/base.tmpl @@ -20,8 +20,6 @@