Fix create-account with global database settings

This commit is contained in:
Till Faelligen 2022-05-12 09:31:51 +02:00
parent 58af7f61b6
commit 9722df46f8
2 changed files with 11 additions and 2 deletions

View file

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

View file

@ -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")
}