Compare commits
No commits in common. "ad1cb56a0614904d5713408b94fa6456ebcaac70" and "f28b5188a6a3b03a8e37e95ab7ceb2471bfaa72c" have entirely different histories.
ad1cb56a06
...
f28b5188a6
@ -286,36 +286,5 @@ func (db *T) CreateUser(username, password, name string) (userID int64, err erro
|
||||
err = row.Scan(&userID)
|
||||
return
|
||||
} // }}}
|
||||
func (db *T) ChangePassword(userID int, currentPassword, newPassword string) (changed bool, err error) { // {{{
|
||||
var res sql.Result
|
||||
res, err = db.Conn.Exec(`
|
||||
UPDATE _webservice.user
|
||||
SET
|
||||
"password" = _webservice.password_hash(
|
||||
/* salt in hex */
|
||||
ENCODE(_webservice.gen_random_bytes(16), 'hex'),
|
||||
|
||||
/* password */
|
||||
$3::bytea
|
||||
)
|
||||
WHERE
|
||||
id = $1 AND
|
||||
"password" = _webservice.password_hash(SUBSTRING(password FROM 1 FOR 32), $2::bytea)
|
||||
|
||||
`,
|
||||
userID,
|
||||
currentPassword,
|
||||
newPassword,
|
||||
)
|
||||
|
||||
var rowsAffected int64
|
||||
rowsAffected, err = res.RowsAffected()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
changed = (rowsAffected == 1)
|
||||
return
|
||||
} // }}}
|
||||
|
||||
// vim: foldmethod=marker
|
||||
|
Loading…
Reference in New Issue
Block a user