diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-09-04 15:16:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-04 15:16:13 +0100 |
commit | 5076925c184998414c3691e97fc21b554abf4a55 (patch) | |
tree | b4da4d8a3015166e16eb9a6009f733653f0485bc /userapi/storage/accounts/postgres/storage.go | |
parent | ca8dcf46b746686e213b184c3ae42ba0be17b46b (diff) |
Password changes (#1397)
* User API support for password changes
* Password changes in client API
* Update sytest-whitelist
* Remove debug logging
* Default logout_devices to true
* Fix deleting devices by local part
Diffstat (limited to 'userapi/storage/accounts/postgres/storage.go')
-rw-r--r-- | userapi/storage/accounts/postgres/storage.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/userapi/storage/accounts/postgres/storage.go b/userapi/storage/accounts/postgres/storage.go index b36264dd..8b9ebef8 100644 --- a/userapi/storage/accounts/postgres/storage.go +++ b/userapi/storage/accounts/postgres/storage.go @@ -112,6 +112,17 @@ func (d *Database) SetDisplayName( return d.profiles.setDisplayName(ctx, localpart, displayName) } +// SetPassword sets the account password to the given hash. +func (d *Database) SetPassword( + ctx context.Context, localpart, plaintextPassword string, +) error { + hash, err := hashPassword(plaintextPassword) + if err != nil { + return err + } + return d.accounts.updatePassword(ctx, localpart, hash) +} + // CreateGuestAccount makes a new guest account and creates an empty profile // for this account. func (d *Database) CreateGuestAccount(ctx context.Context) (acc *api.Account, err error) { |