mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 23:13:11 -06:00
Make it actually work
This commit is contained in:
parent
a647d633dd
commit
542fb36ae1
|
|
@ -41,10 +41,10 @@ const insertAccountSQL = "" +
|
|||
"INSERT INTO accounts(localpart, created_ts, password_hash) VALUES ($1, $2, $3)"
|
||||
|
||||
const selectAccountByLocalpartSQL = "" +
|
||||
"SELECT localpart WHERE localpart = $1"
|
||||
"SELECT localpart FROM accounts WHERE localpart = $1"
|
||||
|
||||
const selectPasswordHashSQL = "" +
|
||||
"SELECT password_hash WHERE localpart = $1"
|
||||
"SELECT password_hash FROM accounts WHERE localpart = $1"
|
||||
|
||||
// TODO: Update password
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ func (s *accountsStatements) prepare(db *sql.DB, server gomatrixserverlib.Server
|
|||
// on success.
|
||||
func (s *accountsStatements) insertAccount(localpart, hash string) (acc *types.Account, err error) {
|
||||
createdTimeMS := time.Now().UnixNano() / 1000000
|
||||
if _, err = s.insertAccountStmt.Exec(localpart, createdTimeMS, hash); err != nil {
|
||||
if _, err = s.insertAccountStmt.Exec(localpart, createdTimeMS, hash); err == nil {
|
||||
acc = &types.Account{
|
||||
Localpart: localpart,
|
||||
UserID: makeUserID(localpart, s.serverName),
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ import (
|
|||
"github.com/matrix-org/dendrite/clientapi/auth/types"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
// Import the postgres database driver.
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
// AccountDatabase represents an account database
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ func main() {
|
|||
}
|
||||
|
||||
queryAPI := api.NewRoomserverQueryAPIHTTP(cfg.RoomserverURL, nil)
|
||||
accountDB, err := storage.NewAccountDatabase("", serverName)
|
||||
accountDB, err := storage.NewAccountDatabase(accountDataSource, serverName)
|
||||
if err != nil {
|
||||
log.Panicf("Failed to setup account database(%s): %s", accountDataSource, err.Error())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue