diff --git a/provision/002_templates/auth.yml b/provision/002_templates/auth.yml index 616e7804b..33bff0d6e 100644 --- a/provision/002_templates/auth.yml +++ b/provision/002_templates/auth.yml @@ -17,13 +17,13 @@ templates:

You will be logged-in after successful reset.

{{template "email_general_footer" .}} - auth_email_email_confirm_subject: + auth_email_confirm_subject: type: text/plain meta: short: Email confirmation subject template: Reset your password - auth_email_email_confirm_content: + auth_email_confirm_content: type: text/html meta: short: Email confirmation content @@ -35,13 +35,13 @@ templates:

You will be logged-in after successful confirmation.

{{template "email_general_footer" .}} - auth_email_email_mfa_subject: + auth_email_mfa_subject: type: text/plain meta: short: MFA login code subject template: Login code - auth_email_email_mfa_content: + auth_email_mfa_content: type: text/html meta: short: MFA login code content diff --git a/system/service/auth_notification.go b/system/service/auth_notification.go index 70b466201..8a17f3049 100644 --- a/system/service/auth_notification.go +++ b/system/service/auth_notification.go @@ -45,13 +45,13 @@ func (svc authNotification) log(ctx context.Context, fields ...zapcore.Field) *z } func (svc authNotification) EmailOTP(ctx context.Context, emailAddress string, code string) error { - return svc.send(ctx, "auth_email_otp", emailAddress, map[string]interface{}{ + return svc.send(ctx, "auth_email_mfa", emailAddress, map[string]interface{}{ "Code": code, }) } func (svc authNotification) EmailConfirmation(ctx context.Context, emailAddress string, token string) error { - return svc.send(ctx, "auth_email_confirmation", emailAddress, map[string]interface{}{ + return svc.send(ctx, "auth_email_confirm", emailAddress, map[string]interface{}{ "URL": fmt.Sprintf("%s/confirm-email?token=%s", svc.opt.BaseURL, url.QueryEscape(token)), }) } @@ -81,16 +81,20 @@ func (svc authNotification) send(ctx context.Context, name, sendTo string, paylo err error tmp []byte ntf = svc.newMail() + hdl string ) // Fetch parts - st, err := svc.ts.FindByHandle(ctx, name+"_subject") + hdl = name + "_subject" + st, err := svc.ts.FindByHandle(ctx, hdl) if err != nil { - return err + return fmt.Errorf("cannot generate auth email with template %s: %w", hdl, err) } - ct, err := svc.ts.FindByHandle(ctx, name+"_content") + + hdl = name + "_content" + ct, err := svc.ts.FindByHandle(ctx, hdl) if err != nil { - return err + return fmt.Errorf("cannot generate auth email with template %s: %w", hdl, err) } // Prepare payload