diff --git a/cmd/create-account/main.go b/cmd/create-account/main.go index 307fa17e6..18a5110bc 100644 --- a/cmd/create-account/main.go +++ b/cmd/create-account/main.go @@ -23,14 +23,12 @@ import ( "os" "strings" + "github.com/matrix-org/dendrite/setup/base" "github.com/sirupsen/logrus" - "golang.org/x/crypto/bcrypt" "golang.org/x/term" "github.com/matrix-org/dendrite/setup" - "github.com/matrix-org/dendrite/setup/config" "github.com/matrix-org/dendrite/userapi/api" - userdb "github.com/matrix-org/dendrite/userapi/storage" ) const usage = `Usage: %s @@ -80,23 +78,14 @@ func main() { pass := getPassword(password, pwdFile, pwdStdin, askPass, os.Stdin) - accountDB, err := userdb.NewDatabase( - &config.DatabaseOptions{ - ConnectionString: cfg.UserAPI.AccountDatabase.ConnectionString, - }, - cfg.Global.ServerName, bcrypt.DefaultCost, - cfg.UserAPI.OpenIDTokenLifetimeMS, - api.DefaultLoginTokenLifetime, - ) - if err != nil { - logrus.Fatalln("Failed to connect to the database:", err.Error()) - } + b := base.NewBaseDendrite(cfg, "create-account") + accountDB := b.CreateAccountsDB() accType := api.AccountTypeUser if *isAdmin { accType = api.AccountTypeAdmin } - + var err error if *resetPassword { err = accountDB.SetPassword(context.Background(), *username, pass) if err != nil {