From 3b49837d167e8770f1054457e172c36109169e51 Mon Sep 17 00:00:00 2001 From: Thibaut Horel Date: Mon, 31 Dec 2018 09:05:29 -0500 Subject: Add password change feature --- store.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'store.go') diff --git a/store.go b/store.go index 5e76cfc..d830150 100644 --- a/store.go +++ b/store.go @@ -25,6 +25,7 @@ type Store interface { NewSession(userId int64) *Session GetUser(name string) (*User, bool) DeleteSession(id string) + ChangePassword(userId int64, hash []byte) } type PgStore struct { @@ -68,10 +69,14 @@ func (store *PgStore) NewSession(userId int64) *Session { } func (store *PgStore) DeleteSession(id string) { - store.Query("DELETE FROM sessions WHERE id = $1", id) + store.Exec("DELETE FROM sessions WHERE id = $1", id) delete(store.sessionCache, id) } +func (store *PgStore) ChangePassword(userId int64, hash []byte) { + store.Exec("UPDATE users SET password=$1 WHERE id=$2", hash, userId) +} + func (store *PgStore) GetUser(name string) (*User, bool) { u := &User{Name: name} row := store.QueryRow( -- cgit v1.2.3-70-g09d2