SendPasswordResetEmail sends password reset email
(email, tokenValue string)
| 83 | |
| 84 | // SendPasswordResetEmail sends password reset email |
| 85 | func (a *App) SendPasswordResetEmail(email, tokenValue string) error { |
| 86 | if email == "" { |
| 87 | return ErrEmailRequired |
| 88 | } |
| 89 | |
| 90 | from, err := GetSenderEmail(a.BaseURL, defaultSender) |
| 91 | if err != nil { |
| 92 | return errors.Wrap(err, "getting the sender email") |
| 93 | } |
| 94 | |
| 95 | data := mailer.EmailResetPasswordTmplData{ |
| 96 | AccountEmail: email, |
| 97 | Token: tokenValue, |
| 98 | BaseURL: a.BaseURL, |
| 99 | } |
| 100 | |
| 101 | if err := a.EmailBackend.SendEmail(mailer.EmailTypeResetPassword, from, []string{email}, data); err != nil { |
| 102 | if errors.Cause(err) == mailer.ErrSMTPNotConfigured { |
| 103 | return ErrInvalidSMTPConfig |
| 104 | } |
| 105 | |
| 106 | return errors.Wrapf(err, "sending password reset email for %s", email) |
| 107 | } |
| 108 | |
| 109 | return nil |
| 110 | } |
| 111 | |
| 112 | // SendPasswordResetAlertEmail sends email that notifies users of a password change |
| 113 | func (a *App) SendPasswordResetAlertEmail(email string) error { |