diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2021-03-02 10:43:25 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-02 10:43:25 +0000 |
commit | f5cf2418776f0117455eb4156eabdc6dbcf9c1ee (patch) | |
tree | 2e671dfd59aaebfe917abced2b9ca748f480f8ca /userapi/storage/accounts/postgres/storage.go | |
parent | 3069079e37510dbda59b2b272ce133ef81832d7b (diff) |
Fix user registration bug (#1777)
Diffstat (limited to 'userapi/storage/accounts/postgres/storage.go')
-rw-r--r-- | userapi/storage/accounts/postgres/storage.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/userapi/storage/accounts/postgres/storage.go b/userapi/storage/accounts/postgres/storage.go index 870756d8..e6adbfd8 100644 --- a/userapi/storage/accounts/postgres/storage.go +++ b/userapi/storage/accounts/postgres/storage.go @@ -170,8 +170,8 @@ func (d *Database) CreateAccount( func (d *Database) createAccount( ctx context.Context, txn *sql.Tx, localpart, plaintextPassword, appserviceID string, ) (*api.Account, error) { + var account *api.Account var err error - // Generate a password hash if this is not a password-less user hash := "" if plaintextPassword != "" { @@ -180,14 +180,16 @@ func (d *Database) createAccount( return nil, err } } - if err := d.profiles.insertProfile(ctx, txn, localpart); err != nil { + if account, err = d.accounts.insertAccount(ctx, txn, localpart, hash, appserviceID); err != nil { if sqlutil.IsUniqueConstraintViolationErr(err) { return nil, sqlutil.ErrUserExists } return nil, err } - - if err := d.accountDatas.insertAccountData(ctx, txn, localpart, "", "m.push_rules", json.RawMessage(`{ + if err = d.profiles.insertProfile(ctx, txn, localpart); err != nil { + return nil, err + } + if err = d.accountDatas.insertAccountData(ctx, txn, localpart, "", "m.push_rules", json.RawMessage(`{ "global": { "content": [], "override": [], @@ -198,7 +200,7 @@ func (d *Database) createAccount( }`)); err != nil { return nil, err } - return d.accounts.insertAccount(ctx, txn, localpart, hash, appserviceID) + return account, nil } // SaveAccountData saves new account data for a given user and a given room. |