mirror of
https://github.com/volatiletech/authboss.git
synced 2025-07-17 01:32:24 +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:
@ -66,6 +66,13 @@ type EmailResponseOptions struct {
|
|||||||
// Email renders the e-mail templates for the given email and
|
// Email renders the e-mail templates for the given email and
|
||||||
// sends it using the mailer.
|
// sends it using the mailer.
|
||||||
func (a *Authboss) Email(ctx context.Context, email Email, ro EmailResponseOptions) error {
|
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 {
|
if len(ro.HTMLTemplate) != 0 {
|
||||||
htmlBody, _, err := a.Core.MailRenderer.Render(ctx, ro.HTMLTemplate, ro.Data)
|
htmlBody, _, err := a.Core.MailRenderer.Render(ctx, ro.HTMLTemplate, ro.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user