aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorS7evinK <2353100+S7evinK@users.noreply.github.com>2022-02-16 18:55:38 +0100
committerGitHub <noreply@github.com>2022-02-16 18:55:38 +0100
commit5a39512f5f35b13adea3afc2e366e01ec73924de (patch)
treeac0e5cd6de8798e45cf0b5b37440ae08f4c7ba90 /cmd
parente9b672a34e08bce9d12b2a2454c19fde6e52036e (diff)
Add account type (#2171)
* Add account_type for sqlite3 * Add account_type for postgres * Remove CreateGuestAccount from interface * Add new AccountTypes & update test * Use newly added AccountType for account creation * Add migrations * Reuse type * Add AccounnType to Device, so it can be verified on requests * Rename migration, add missing update for appservices * Rename sqlite3 migration * Add missing AccountType to return value * Update sqlite migration Change allowance check on /admin/whois * Fix migration, add IS NULL * Move accountType to completeRegistration * Fix migrations * Add passing test
Diffstat (limited to 'cmd')
-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())
}