aboutsummaryrefslogtreecommitdiff
path: root/auth_mtpostgresql.go
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-07-18 18:43:11 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-07-18 18:43:11 +0200
commitedcab78dd4b5fcf06e27c3d0d00c57567d68f66a (patch)
treebec4b9d7c954c57be3123911b3534781648ae110 /auth_mtpostgresql.go
parent586bb646cf388b2bb6902b755a6967e4d007a63f (diff)
fix UPSERTion of postgres users / passwords
Diffstat (limited to 'auth_mtpostgresql.go')
-rw-r--r--auth_mtpostgresql.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/auth_mtpostgresql.go b/auth_mtpostgresql.go
index ffd932c..fe4b9c7 100644
--- a/auth_mtpostgresql.go
+++ b/auth_mtpostgresql.go
@@ -134,7 +134,7 @@ func (a *AuthMTPostgreSQL) Passwd(name string) (salt, verifier []byte, err error
func (a *AuthMTPostgreSQL) SetPasswd(name string, salt, verifier []byte) error {
encodedPasswd := encodeVerifierAndSalt(salt, verifier)
- _, err := a.db.Exec("REPLACE INTO auth (name, password, last_login) VALUES ($1, $2, unixepoch());", name, encodedPasswd)
+ _, err := a.db.Exec("INSERT INTO auth (name, password, last_login) VALUES ($1, $2, extract(epoch from now())) ON CONFLICT (name) DO UPDATE SET password = EXCLUDED.password, last_login = extract(epoch from now());", name, encodedPasswd)
return err
}