// POST /authenticate func PostAuthenticate(r render.Render, req *http.Request) { email := req.PostFormValue("email") password := req.PostFormValue("password") session_id, err := db.Auth(email, password) if err != nil { r.Error(401) } else { r.JSON(200, map[string]interface{}{"session": session_id}) } }
// POST /auth func PostAuth(s sessions.Session, r render.Render, req *http.Request) { email := req.PostFormValue("email") password := req.PostFormValue("password") session_id, err := db.Auth(email, password) if err != nil { r.Error(401) } else { s.Set("user_session", session_id) r.Redirect("/") } }