From de58f0251ebd02372b7598cd428772bae8db09a2 Mon Sep 17 00:00:00 2001 From: Las Zenow Date: Thu, 22 Feb 2018 09:57:37 +0000 Subject: [PATCH] Fix setting password We were not acting on the error returning, and the sql sintax was wrong. --- lib/database/users.go | 4 ++-- lib/user.go | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/database/users.go b/lib/database/users.go index 0909bd4..ad46164 100644 --- a/lib/database/users.go +++ b/lib/database/users.go @@ -74,8 +74,8 @@ func (db *pgDB) SetPassword(name string, pass string) error { if err != nil { return err } - _, err = db.sql.Model(user{}). - Set("pass = ?, salt = ?", hash, salt). + _, err = db.sql.Model(&user{}). + Set("password = ?, salt = ?", hash, salt). Where("username = ?", name). Update() return err diff --git a/lib/user.go b/lib/user.go index 8f20dc2..4657f7e 100644 --- a/lib/user.go +++ b/lib/user.go @@ -79,8 +79,13 @@ func settingsHandler(h handler) { case pass1 != pass2: h.sess.Notify("Passwords don't match!", "The new password and the confirmation password don't match. Try again", "error") default: - h.db.SetPassword(h.sess.User, pass1) - h.sess.Notify("Password updated!", "Your new password is correctly set.", "success") + err := h.db.SetPassword(h.sess.User, pass1) + 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) }