Load templates into one variable
This commit is contained in:
parent
fb95331aa2
commit
219a15c4c3
|
@ -134,7 +134,7 @@ func checkConsent(ctx context.Context, userID string, userAPI userapi.UserIntern
|
|||
}{
|
||||
ConsentURL: uri,
|
||||
}
|
||||
if err = userConsentCfg.BlockEventsTemplate.ExecuteTemplate(msg, "blockEventsError", c); err != nil {
|
||||
if err = userConsentCfg.TextTemplates.ExecuteTemplate(msg, "blockEventsError", c); err != nil {
|
||||
logrus.Infof("error consent message: %+v", err)
|
||||
return jsonerror.Unknown("unable to get consent URL")
|
||||
}
|
||||
|
|
|
@ -288,7 +288,7 @@ func (config *Dendrite) Derive() error {
|
|||
// TODO: Add email auth type
|
||||
// TODO: Add MSISDN auth type
|
||||
|
||||
if config.Global.UserConsentOptions.RequireAtRegistration {
|
||||
if config.Global.UserConsentOptions.Enabled && config.Global.UserConsentOptions.RequireAtRegistration {
|
||||
uri := config.Global.BaseURL + "/_matrix/consent?v=" + config.Global.UserConsentOptions.Version
|
||||
config.Derived.Registration.Params[authtypes.LoginTypeTerms] = Terms{
|
||||
Policies: Policies{
|
||||
|
@ -314,7 +314,7 @@ func (config *Dendrite) Derive() error {
|
|||
|
||||
// prepend each flow with LoginTypeTerms or LoginTypeRecaptcha
|
||||
for i, flow := range config.Derived.Registration.Flows {
|
||||
if config.Global.UserConsentOptions.RequireAtRegistration {
|
||||
if config.Global.UserConsentOptions.Enabled && config.Global.UserConsentOptions.RequireAtRegistration {
|
||||
flow.Stages = append([]authtypes.LoginType{authtypes.LoginTypeTerms}, flow.Stages...)
|
||||
}
|
||||
if config.ClientAPI.RecaptchaEnabled {
|
||||
|
|
|
@ -266,9 +266,9 @@ type UserConsentOptions struct {
|
|||
// The error message to display if the user hasn't given their consent yet
|
||||
BlockEventsError string `yaml:"block_events_error"`
|
||||
// All loaded templates
|
||||
Templates *template.Template `yaml:"-"`
|
||||
BlockEventsTemplate *textTemplate.Template `yaml:"-"`
|
||||
//
|
||||
Templates *template.Template `yaml:"-"`
|
||||
TextTemplates *textTemplate.Template `yaml:"-"`
|
||||
// The BaseURL, used for building the consent URL
|
||||
BaseURL string `yaml:"-"`
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,8 @@ func (c *UserConsentOptions) Verify(configErrors *ConfigErrors, isMonolith bool)
|
|||
return
|
||||
}
|
||||
|
||||
c.BlockEventsTemplate = textTemplate.Must(textTemplate.New("blockEventsError").Parse(c.BlockEventsError))
|
||||
c.TextTemplates = textTemplate.Must(textTemplate.New("blockEventsError").Parse(c.BlockEventsError))
|
||||
c.TextTemplates = textTemplate.Must(c.TextTemplates.New("serverNoticeTemplate").Parse(c.ServerNoticeContent.Body))
|
||||
|
||||
// Read all defined *.gohtml templates
|
||||
t, err := template.ParseGlob(filepath.Join(p, "*.gohtml"))
|
||||
|
|
Loading…
Reference in a new issue