From f549169a1ebc46bed4edf6b9fcb660b91a076453 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 23 Mar 2015 16:16:02 -0800 Subject: [PATCH] JSON payload for auth --- users.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/users.go b/users.go index 1622631..6c9264e 100644 --- a/users.go +++ b/users.go @@ -49,10 +49,15 @@ type UserSession struct { } func serveAuthenticateUser(w http.ResponseWriter, r *http.Request) { - username := r.FormValue("username") - password := r.FormValue("password") - - user_session, err := dbAuthenticate(username, password) + var a struct { + Username string + Password string + } + if err := json.NewDecoder(r.Body).Decode(&a); err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + user_session, err := dbAuthenticate(a.Username, a.Password) if err != nil { w.WriteHeader(http.StatusUnauthorized) return