This commit is contained in:
Till Faelligen 2022-03-12 09:01:42 +01:00
parent 01d71a767d
commit 7a73ddbe12

View file

@ -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 {