aboutsummaryrefslogtreecommitdiff
path: root/cmd/create-account/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/create-account/main.go')
-rw-r--r--cmd/create-account/main.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/cmd/create-account/main.go b/cmd/create-account/main.go
index 3ac07770..d9202eb0 100644
--- a/cmd/create-account/main.go
+++ b/cmd/create-account/main.go
@@ -23,12 +23,14 @@ import (
"os"
"strings"
- "github.com/matrix-org/dendrite/setup"
- "github.com/matrix-org/dendrite/setup/config"
- "github.com/matrix-org/dendrite/userapi/storage/accounts"
"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"
+ "github.com/matrix-org/dendrite/userapi/storage/accounts"
)
const usage = `Usage: %s
@@ -57,6 +59,7 @@ var (
pwdFile = flag.String("passwordfile", "", "The file to use for the password (e.g. for automated account creation)")
pwdStdin = flag.Bool("passwordstdin", false, "Reads the password from stdin")
askPass = flag.Bool("ask-pass", false, "Ask for the password to use")
+ isAdmin = flag.Bool("admin", false, "Create an admin account")
)
func main() {
@@ -81,7 +84,11 @@ func main() {
logrus.Fatalln("Failed to connect to the database:", err.Error())
}
- _, err = accountDB.CreateAccount(context.Background(), *username, pass, "")
+ accType := api.AccountTypeUser
+ if *isAdmin {
+ accType = api.AccountTypeAdmin
+ }
+ _, err = accountDB.CreateAccount(context.Background(), *username, pass, "", accType)
if err != nil {
logrus.Fatalln("Failed to create the account:", err.Error())
}