backend: moved to correct plaintext mail parsing

This commit is contained in:
Alex
2025-02-26 21:44:24 +01:00
parent a2886fc1e0
commit 7c01b77445
11 changed files with 328 additions and 120 deletions

View File

@@ -80,6 +80,34 @@ func (s *EmailService) SendVerificationEmail(user *models.User, token *string) e
return err
}
return s.SendEmail(user.Email, subject, body, "")
func (s *EmailService) SendChangePasswordEmail(user *models.User, token *string) error {
// Prepare data to be injected into the template
data := struct {
FirstName string
LastName string
Token string
BASEURL string
UserID uint
}{
FirstName: user.FirstName,
LastName: user.LastName,
Token: *token,
BASEURL: config.Site.BaseURL,
UserID: user.ID,
}
subject := constants.MailChangePasswordSubject
htmlBody, err := ParseTemplate("mail_change_password.tmpl", data)
if err != nil {
logger.Error.Print("Couldn't parse password mail")
return err
}
plainBody, err := ParseTemplate("mail_change_password.txt.tmpl", data)
if err != nil {
logger.Error.Print("Couldn't parse password mail")
return err
}
return s.SendEmail(user.Email, subject, htmlBody, plainBody, "")
}