diff --git a/api/v1/authentication.go b/api/v1/authentication.go index b7459eb..9747f4d 100644 --- a/api/v1/authentication.go +++ b/api/v1/authentication.go @@ -197,7 +197,7 @@ func (s *Server) signupAuth() http.HandlerFunc { w.WriteHeader(http.StatusUnauthorized) } - err = s.mailer.SendVerMail(&newUser, s.templates) + err = s.mailer.SendVerMail(&newUser, s.domain, s.templates) if err != nil { span.RecordError(err) span.SetStatus(codes.Error, err.Error()) @@ -389,7 +389,7 @@ func (s *Server) resendVer() http.HandlerFunc { } user.VerificationCode = utils.RandomString(6) user.ExpirationTime = time.Now().Add(time.Minute * 5) - err = s.mailer.SendVerMail(user, s.templates) + err = s.mailer.SendVerMail(user, s.domain, s.templates) if err != nil { span.RecordError(err) span.SetStatus(codes.Error, err.Error()) diff --git a/api/v1/mailservice.go b/api/v1/mailservice.go index 6b44025..9d110bc 100644 --- a/api/v1/mailservice.go +++ b/api/v1/mailservice.go @@ -7,6 +7,6 @@ import ( // interface for Mailerservice for Verification-Mail and Reset-PW-Mail type Mailerservice interface { - SendVerMail(*model.User, *templates.TemplateHandler) error + SendVerMail(*model.User, string, *templates.TemplateHandler) error SendPWMail(*model.User, *templates.TemplateHandler) error } diff --git a/internal/mailer/mailer.go b/internal/mailer/mailer.go index 9f37561..bb4671e 100644 --- a/internal/mailer/mailer.go +++ b/internal/mailer/mailer.go @@ -29,9 +29,20 @@ func NewMailer( } } -func (m *Mailer) SendVerMail(user *model.User, tmpl *templates.TemplateHandler) error { +type data struct { + User *model.User + Domain string +} + +func (m *Mailer) SendVerMail(user *model.User, domain string, tmpl *templates.TemplateHandler) error { var body bytes.Buffer - err := tmpl.TmplVerMail.Execute(&body, user) + + data := &data{ + User: user, + Domain: domain, + } + + err := tmpl.TmplVerMail.Execute(&body, data) if err != nil { return err } diff --git a/internal/templates/auth/verMail.html b/internal/templates/auth/verMail.html index acf0bf3..53017fd 100644 --- a/internal/templates/auth/verMail.html +++ b/internal/templates/auth/verMail.html @@ -12,9 +12,9 @@
- Hello {{ .Name }}, this is your verification code: {{ .VerificationCode }} - Please enter your code here: - Link to Verification-Website + Hello {{ .User.Name }}, this is your verification code: {{ + .User.VerificationCode }} Please enter your code here: + Link to Verification-Website