1
0
mirror of https://github.com/volatiletech/authboss.git synced 2024-11-24 08:42:17 +02:00

add the context data before rendering emails

In Responder.Respond() all context data is merged into the HTMLData before continuing to the HTML rendering. This commit does the same for emails, to make personalized emails possible.
This commit is contained in:
Gys 2019-10-12 13:00:56 +01:00 committed by GitHub
parent 4d85b23e8a
commit 8c6ebdc085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,6 +66,13 @@ type EmailResponseOptions struct {
// Email renders the e-mail templates for the given email and
// sends it using the mailer.
func (a *Authboss) Email(ctx context.Context, email Email, ro EmailResponseOptions) error {
ctxData := ctx.Value(CTXKeyData)
if ctxData != nil {
if ro.Data == nil {
ro.Data = HTMLData{}
}
ro.Data.Merge(ctxData.(HTMLData))
}
if len(ro.HTMLTemplate) != 0 {
htmlBody, _, err := a.Core.MailRenderer.Render(ctx, ro.HTMLTemplate, ro.Data)
if err != nil {