Skip to content

Commit

Permalink
fix: initialise empty map for email template (#3032)
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatybridge authored Jan 11, 2025
1 parent 55fc704 commit 76272d3
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 56 deletions.
96 changes: 48 additions & 48 deletions pkg/config/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,60 +442,60 @@ func (e *email) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) {
if len(e.Template) == 0 {
return
}
var tmpl emailTemplate
tmpl = e.Template["invite"]
if tmpl.Subject != nil {
tmpl.Subject = remoteConfig.MailerSubjectsInvite
}
if tmpl.Content != nil {
tmpl.Content = remoteConfig.MailerTemplatesInviteContent
}
e.Template["invite"] = tmpl

tmpl = e.Template["confirmation"]
if tmpl.Subject != nil {
tmpl.Subject = remoteConfig.MailerSubjectsConfirmation
}
if tmpl.Content != nil {
tmpl.Content = remoteConfig.MailerTemplatesConfirmationContent
}
e.Template["confirmation"] = tmpl

tmpl = e.Template["recovery"]
if tmpl.Subject != nil {
tmpl.Subject = remoteConfig.MailerSubjectsRecovery
}
if tmpl.Content != nil {
tmpl.Content = remoteConfig.MailerTemplatesRecoveryContent
}
e.Template["recovery"] = tmpl

tmpl = e.Template["magic_link"]
if tmpl.Subject != nil {
tmpl.Subject = remoteConfig.MailerSubjectsMagicLink
if t, ok := e.Template["invite"]; ok {
if t.Subject != nil {
t.Subject = remoteConfig.MailerSubjectsInvite
}
if t.Content != nil {
t.Content = remoteConfig.MailerTemplatesInviteContent
}
e.Template["invite"] = t
}
if tmpl.Content != nil {
tmpl.Content = remoteConfig.MailerTemplatesMagicLinkContent
if t, ok := e.Template["confirmation"]; ok {
if t.Subject != nil {
t.Subject = remoteConfig.MailerSubjectsConfirmation
}
if t.Content != nil {
t.Content = remoteConfig.MailerTemplatesConfirmationContent
}
e.Template["confirmation"] = t
}
e.Template["magic_link"] = tmpl

tmpl = e.Template["email_change"]
if tmpl.Subject != nil {
tmpl.Subject = remoteConfig.MailerSubjectsEmailChange
if t, ok := e.Template["recovery"]; ok {
if t.Subject != nil {
t.Subject = remoteConfig.MailerSubjectsRecovery
}
if t.Content != nil {
t.Content = remoteConfig.MailerTemplatesRecoveryContent
}
e.Template["recovery"] = t
}
if tmpl.Content != nil {
tmpl.Content = remoteConfig.MailerTemplatesEmailChangeContent
if t, ok := e.Template["magic_link"]; ok {
if t.Subject != nil {
t.Subject = remoteConfig.MailerSubjectsMagicLink
}
if t.Content != nil {
t.Content = remoteConfig.MailerTemplatesMagicLinkContent
}
e.Template["magic_link"] = t
}
e.Template["email_change"] = tmpl

tmpl = e.Template["reauthentication"]
if tmpl.Subject != nil {
tmpl.Subject = remoteConfig.MailerSubjectsReauthentication
if t, ok := e.Template["email_change"]; ok {
if t.Subject != nil {
t.Subject = remoteConfig.MailerSubjectsEmailChange
}
if t.Content != nil {
t.Content = remoteConfig.MailerTemplatesEmailChangeContent
}
e.Template["email_change"] = t
}
if tmpl.Content != nil {
tmpl.Content = remoteConfig.MailerTemplatesReauthenticationContent
if t, ok := e.Template["reauthentication"]; ok {
if t.Subject != nil {
t.Subject = remoteConfig.MailerSubjectsReauthentication
}
if t.Content != nil {
t.Content = remoteConfig.MailerTemplatesReauthenticationContent
}
e.Template["reauthentication"] = t
}
e.Template["reauthentication"] = tmpl
}

func (s smtp) IsEnabled() bool {
Expand Down
9 changes: 1 addition & 8 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,7 @@ func NewConfig(editors ...ConfigEditor) config {
Auth: auth{
Image: gotrueImage,
Email: email{
Template: map[string]emailTemplate{
"invite": {},
"confirmation": {},
"recovery": {},
"magic_link": {},
"email_change": {},
"reauthentication": {},
},
Template: map[string]emailTemplate{},
},
Sms: sms{
TestOTP: map[string]string{},
Expand Down

0 comments on commit 76272d3

Please sign in to comment.