From 9722df46f84122f5239004f520759824250b3d95 Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Thu, 12 May 2022 09:31:51 +0200 Subject: [PATCH] Fix create-account with global database settings --- cmd/create-account/main.go | 6 +++++- setup/base/base.go | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/create-account/main.go b/cmd/create-account/main.go index 7a5660522..9c0e71870 100644 --- a/cmd/create-account/main.go +++ b/cmd/create-account/main.go @@ -25,6 +25,7 @@ import ( "strings" "github.com/matrix-org/dendrite/setup" + "github.com/matrix-org/dendrite/setup/base" "github.com/matrix-org/dendrite/userapi/api" "github.com/matrix-org/dendrite/userapi/storage" "github.com/sirupsen/logrus" @@ -99,8 +100,11 @@ func main() { } } + b := base.NewBaseDendrite(cfg, "", base.CreateAccountMode) + defer b.Close() // nolint: errcheck + accountDB, err := storage.NewUserAPIDatabase( - nil, + b, &cfg.UserAPI.AccountDatabase, cfg.Global.ServerName, cfg.UserAPI.BCryptCost, diff --git a/setup/base/base.go b/setup/base/base.go index 5cbd7da9c..9027ccc2e 100644 --- a/setup/base/base.go +++ b/setup/base/base.go @@ -100,6 +100,7 @@ const ( DisableMetrics BaseDendriteOptions = iota UseHTTPAPIs PolylithMode + CreateAccountMode ) // NewBaseDendrite creates a new instance to be used by a component. @@ -110,6 +111,7 @@ func NewBaseDendrite(cfg *config.Dendrite, componentName string, options ...Base useHTTPAPIs := false enableMetrics := true isMonolith := true + createAccountMode := false for _, opt := range options { switch opt { case DisableMetrics: @@ -119,6 +121,9 @@ func NewBaseDendrite(cfg *config.Dendrite, componentName string, options ...Base case PolylithMode: isMonolith = false useHTTPAPIs = true + case CreateAccountMode: + createAccountMode = true + cfg.ClientAPI.OpenRegistrationWithoutVerificationEnabled = true } } @@ -137,7 +142,7 @@ func NewBaseDendrite(cfg *config.Dendrite, componentName string, options ...Base logrus.Infof("Dendrite version %s", internal.VersionString()) - if !cfg.ClientAPI.RegistrationDisabled && cfg.ClientAPI.OpenRegistrationWithoutVerificationEnabled { + if !createAccountMode && !cfg.ClientAPI.RegistrationDisabled && cfg.ClientAPI.OpenRegistrationWithoutVerificationEnabled { logrus.Warn("Open registration is enabled") }