// POST /files/delete func DeleteUsers(w http.ResponseWriter, r *http.Request) { r.ParseForm() id, _ := strconv.ParseInt(r.FormValue("Id"), 10, 64) user, _ := models.FindUser(id) models.DeleteUser(user) http.Redirect(w, r, "/admin/users", http.StatusFound) }
func AuthMiddleware() negroni.HandlerFunc { return func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) { w.Header().Set("Cache-Control", "private, no-cache") session, err := CookieStore.Get(r, "auth") if err != nil { log.Println("Error parsing auth cookie", err) } user_id := session.Values["userid"] if user_id != nil { _, err = models.FindUser(user_id.(int64)) if err != nil { http.Redirect(w, r, "/login", http.StatusFound) } else { next(w, r) } } else { http.Redirect(w, r, "/login", http.StatusFound) } } }