mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-08 15:33:09 -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)"
|
"INSERT INTO accounts(localpart, created_ts, password_hash) VALUES ($1, $2, $3)"
|
||||||
|
|
||||||
const selectAccountByLocalpartSQL = "" +
|
const selectAccountByLocalpartSQL = "" +
|
||||||
"SELECT localpart WHERE localpart = $1"
|
"SELECT localpart FROM accounts WHERE localpart = $1"
|
||||||
|
|
||||||
const selectPasswordHashSQL = "" +
|
const selectPasswordHashSQL = "" +
|
||||||
"SELECT password_hash WHERE localpart = $1"
|
"SELECT password_hash FROM accounts WHERE localpart = $1"
|
||||||
|
|
||||||
// TODO: Update password
|
// TODO: Update password
|
||||||
|
|
||||||
|
|
@ -78,7 +78,7 @@ func (s *accountsStatements) prepare(db *sql.DB, server gomatrixserverlib.Server
|
||||||
// on success.
|
// on success.
|
||||||
func (s *accountsStatements) insertAccount(localpart, hash string) (acc *types.Account, err error) {
|
func (s *accountsStatements) insertAccount(localpart, hash string) (acc *types.Account, err error) {
|
||||||
createdTimeMS := time.Now().UnixNano() / 1000000
|
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{
|
acc = &types.Account{
|
||||||
Localpart: localpart,
|
Localpart: localpart,
|
||||||
UserID: makeUserID(localpart, s.serverName),
|
UserID: makeUserID(localpart, s.serverName),
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ import (
|
||||||
"github.com/matrix-org/dendrite/clientapi/auth/types"
|
"github.com/matrix-org/dendrite/clientapi/auth/types"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
|
// Import the postgres database driver.
|
||||||
|
_ "github.com/lib/pq"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AccountDatabase represents an account database
|
// AccountDatabase represents an account database
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
queryAPI := api.NewRoomserverQueryAPIHTTP(cfg.RoomserverURL, nil)
|
queryAPI := api.NewRoomserverQueryAPIHTTP(cfg.RoomserverURL, nil)
|
||||||
accountDB, err := storage.NewAccountDatabase("", serverName)
|
accountDB, err := storage.NewAccountDatabase(accountDataSource, serverName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("Failed to setup account database(%s): %s", accountDataSource, err.Error())
|
log.Panicf("Failed to setup account database(%s): %s", accountDataSource, err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue