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) {
|
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
|
||||||
|
|
Reference in a new issue