fix users saving error

Former-commit-id: 576b58ada315786617dcef59871afbe0b42ff1ab [formerly a5dda4206830542195b8345e53d11dd5bacb91c8] [formerly bc39f4fe99bfb88beceafcdfd5d9ca60e99bdd9a [formerly eab46841b1]]
Former-commit-id: 47773a49d83fc03a8c9ef79ac4295a5916a6d510 [formerly 1aef90af373acdea7e62ab355ff3fb0a994cc62b]
Former-commit-id: 8892e93d80931384c92f39ab9bcb80a2dfdfb7cf
This commit is contained in:
Henrique Dias 2017-07-26 18:08:49 +01:00
parent 4d1fb15aee
commit adfd5e8645

View File

@ -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
}