JSON payload for auth

This commit is contained in:
Matthew Dillon 2015-03-23 16:16:02 -08:00
parent 29463e8468
commit f549169a1e

View file

@ -49,10 +49,15 @@ type UserSession struct {
} }
func serveAuthenticateUser(w http.ResponseWriter, r *http.Request) { func serveAuthenticateUser(w http.ResponseWriter, r *http.Request) {
username := r.FormValue("username") var a struct {
password := r.FormValue("password") Username string
Password string
user_session, err := dbAuthenticate(username, password) }
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 { if err != nil {
w.WriteHeader(http.StatusUnauthorized) w.WriteHeader(http.StatusUnauthorized)
return return