JSON payload for auth
This commit is contained in:
parent
29463e8468
commit
f549169a1e
1 changed files with 9 additions and 4 deletions
13
users.go
13
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
|
||||
|
|
Reference in a new issue