From 8c6ebdc08532385c7a9d27b79f9a5cea0f98972a Mon Sep 17 00:00:00 2001 From: Gys Date: Sat, 12 Oct 2019 13:00:56 +0100 Subject: [PATCH] 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. --- response.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/response.go b/response.go index 7b9368a..e6c4fdd 100644 --- a/response.go +++ b/response.go @@ -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 {