mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-01 03:03:10 -06:00
Fix #2272
This commit is contained in:
parent
01d71a767d
commit
7a73ddbe12
|
|
@ -23,14 +23,12 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/setup/base"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/crypto/bcrypt"
|
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/setup"
|
"github.com/matrix-org/dendrite/setup"
|
||||||
"github.com/matrix-org/dendrite/setup/config"
|
|
||||||
"github.com/matrix-org/dendrite/userapi/api"
|
"github.com/matrix-org/dendrite/userapi/api"
|
||||||
userdb "github.com/matrix-org/dendrite/userapi/storage"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const usage = `Usage: %s
|
const usage = `Usage: %s
|
||||||
|
|
@ -80,23 +78,14 @@ func main() {
|
||||||
|
|
||||||
pass := getPassword(password, pwdFile, pwdStdin, askPass, os.Stdin)
|
pass := getPassword(password, pwdFile, pwdStdin, askPass, os.Stdin)
|
||||||
|
|
||||||
accountDB, err := userdb.NewDatabase(
|
b := base.NewBaseDendrite(cfg, "create-account")
|
||||||
&config.DatabaseOptions{
|
accountDB := b.CreateAccountsDB()
|
||||||
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())
|
|
||||||
}
|
|
||||||
|
|
||||||
accType := api.AccountTypeUser
|
accType := api.AccountTypeUser
|
||||||
if *isAdmin {
|
if *isAdmin {
|
||||||
accType = api.AccountTypeAdmin
|
accType = api.AccountTypeAdmin
|
||||||
}
|
}
|
||||||
|
var err error
|
||||||
if *resetPassword {
|
if *resetPassword {
|
||||||
err = accountDB.SetPassword(context.Background(), *username, pass)
|
err = accountDB.SetPassword(context.Background(), *username, pass)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue