From eab46841b1b7c20c944d729730aa48530c85f3f5 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 26 Jul 2017 18:08:49 +0100 Subject: [PATCH] fix users saving error --- users.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/users.go b/users.go index 7e99acb4..6eab4e03 100644 --- a/users.go +++ b/users.go @@ -66,7 +66,7 @@ func getUser(r *http.Request) (*User, error) { return nil, errEmptyRequest } - var u *User + u := &User{} err := json.NewDecoder(r.Body).Decode(u) if err != nil { @@ -161,7 +161,7 @@ func usersPostHandler(c *RequestContext, w http.ResponseWriter, r *http.Request) u.Password = pw // Saves the user to the database. - err = c.FM.db.Save(&u) + err = c.FM.db.Save(u) if err == storm.ErrAlreadyExists { return http.StatusConflict, errUserExist } @@ -319,7 +319,7 @@ func usersPutHandler(c *RequestContext, w http.ResponseWriter, r *http.Request) // Updates the whole User struct because we always are supposed // to send a new entire object. - err = c.FM.db.Save(&u) + err = c.FM.db.Save(u) if err != nil { return http.StatusInternalServerError, err }