package ui import ( "html/template" "log" "net/http" "streifling.com/jason/cpolis/cmd/data" ) func Login(db *data.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { user := r.PostFormValue("username") pass := r.PostFormValue("password") id, err := db.GetID(user) if err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) return } if err := db.CheckPassword(id, pass); err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) return } tmpl, err := template.ParseFiles("web/templates/hub.html") template.Must(tmpl, err).ExecuteTemplate(w, "page-content", nil) } }