MCPcopy
hub / github.com/dnote/dnote / SendPasswordResetEmail

Method SendPasswordResetEmail

pkg/server/app/email.go:85–110  ·  view source on GitHub ↗

SendPasswordResetEmail sends password reset email

(email, tokenValue string)

Source from the content-addressed store, hash-verified

83
84// SendPasswordResetEmail sends password reset email
85func (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
113func (a *App) SendPasswordResetAlertEmail(email string) error {

Callers 2

CreateResetTokenMethod · 0.80

Calls 2

GetSenderEmailFunction · 0.85
SendEmailMethod · 0.65

Tested by 1