diff --git a/cmd/frontend/sessions.go b/cmd/frontend/sessions.go index b2f94de..e546a8c 100644 --- a/cmd/frontend/sessions.go +++ b/cmd/frontend/sessions.go @@ -54,19 +54,20 @@ func HomePage(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc { log.Fatalln(err) } - files := []string{c.WebDir + "/templates/index.html"} + files := make([]string, 2) + files[0] = c.WebDir + "/templates/index.html" if numRows == 0 { - files = append(files, c.WebDir+"/templates/first-user.html") + files[1] = c.WebDir + "/templates/first-user.html" tmpl, err := template.ParseFiles(files...) template.Must(tmpl, err).Execute(w, nil) } else { session, _ := s.Get(r, "cookie") if auth, ok := session.Values["authenticated"].(bool); auth && ok { - files = append(files, c.WebDir+"/templates/hub.html") + files[1] = c.WebDir + "/templates/hub.html" tmpl, err := template.ParseFiles(files...) template.Must(tmpl, err).Execute(w, session.Values["role"]) } else { - files = append(files, c.WebDir+"/templates/login.html") + files[1] = c.WebDir + "/templates/login.html" tmpl, err := template.ParseFiles(files...) template.Must(tmpl, err).Execute(w, nil) }