Fix setting password
We were not acting on the error returning, and the sql sintax was wrong.
This commit is contained in:
parent
22065852b2
commit
de58f0251e
2 changed files with 9 additions and 4 deletions
|
@ -74,8 +74,8 @@ func (db *pgDB) SetPassword(name string, pass string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = db.sql.Model(user{}).
|
_, err = db.sql.Model(&user{}).
|
||||||
Set("pass = ?, salt = ?", hash, salt).
|
Set("password = ?, salt = ?", hash, salt).
|
||||||
Where("username = ?", name).
|
Where("username = ?", name).
|
||||||
Update()
|
Update()
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -79,8 +79,13 @@ func settingsHandler(h handler) {
|
||||||
case pass1 != pass2:
|
case pass1 != pass2:
|
||||||
h.sess.Notify("Passwords don't match!", "The new password and the confirmation password don't match. Try again", "error")
|
h.sess.Notify("Passwords don't match!", "The new password and the confirmation password don't match. Try again", "error")
|
||||||
default:
|
default:
|
||||||
h.db.SetPassword(h.sess.User, pass1)
|
err := h.db.SetPassword(h.sess.User, pass1)
|
||||||
h.sess.Notify("Password updated!", "Your new password is correctly set.", "success")
|
if err != nil {
|
||||||
|
log.Warn("Can't update password for user ", h.sess.User, ": ", err)
|
||||||
|
h.sess.Notify("Password error!", "An error has ocurred updating the password in the database. Sorry.", "error")
|
||||||
|
} else {
|
||||||
|
h.sess.Notify("Password updated!", "Your new password is correctly set.", "success")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
h.sess.Save(h.w, h.r)
|
h.sess.Save(h.w, h.r)
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue