aboutsummaryrefslogtreecommitdiffstats
path: root/store.go
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2018-12-31 09:05:29 -0500
committerThibaut Horel <thibaut.horel@gmail.com>2018-12-31 09:05:29 -0500
commit3b49837d167e8770f1054457e172c36109169e51 (patch)
tree9ae844c7851f3f35aea677ebf4a8f80924f76045 /store.go
parent6ae97fe4d7c4fa1c80571d41c356453199041067 (diff)
downloadid-3b49837d167e8770f1054457e172c36109169e51.tar.gz
Add password change feature
Diffstat (limited to 'store.go')
-rw-r--r--store.go7
1 files changed, 6 insertions, 1 deletions
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(