diff options
| author | Thibaut Horel <thibaut.horel@gmail.com> | 2018-12-31 09:05:29 -0500 |
|---|---|---|
| committer | Thibaut Horel <thibaut.horel@gmail.com> | 2018-12-31 09:05:29 -0500 |
| commit | 3b49837d167e8770f1054457e172c36109169e51 (patch) | |
| tree | 9ae844c7851f3f35aea677ebf4a8f80924f76045 /store.go | |
| parent | 6ae97fe4d7c4fa1c80571d41c356453199041067 (diff) | |
| download | id-3b49837d167e8770f1054457e172c36109169e51.tar.gz | |
Add password change feature
Diffstat (limited to 'store.go')
| -rw-r--r-- | store.go | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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( |
