summaryrefslogtreecommitdiff
path: root/internal/email/reset.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/email/reset.go')
-rw-r--r--internal/email/reset.go33
1 files changed, 20 insertions, 13 deletions
diff --git a/internal/email/reset.go b/internal/email/reset.go
index 0b950c1c9..cb1da9fee 100644
--- a/internal/email/reset.go
+++ b/internal/email/reset.go
@@ -20,6 +20,8 @@ package email
import (
"bytes"
"net/smtp"
+
+ "github.com/superseriousbusiness/gotosocial/internal/gtserror"
)
const (
@@ -27,6 +29,19 @@ const (
resetSubject = "GoToSocial Password Reset"
)
+// ResetData represents data passed into the reset email address template.
+type ResetData struct {
+ // Username to be addressed.
+ Username string
+ // URL of the instance to present to the receiver.
+ InstanceURL string
+ // Name of the instance to present to the receiver.
+ InstanceName string
+ // Link to present to the receiver to click on and begin the reset process.
+ // Should be a full link with protocol eg., https://example.org/reset_password?token=some-reset-password-token
+ ResetLink string
+}
+
func (s *sender) SendResetEmail(toAddress string, data ResetData) error {
buf := &bytes.Buffer{}
if err := s.template.ExecuteTemplate(buf, resetTemplate, data); err != nil {
@@ -38,18 +53,10 @@ func (s *sender) SendResetEmail(toAddress string, data ResetData) error {
if err != nil {
return err
}
- return smtp.SendMail(s.hostAddress, s.auth, s.from, []string{toAddress}, msg)
-}
-// ResetData represents data passed into the reset email address template.
-type ResetData struct {
- // Username to be addressed.
- Username string
- // URL of the instance to present to the receiver.
- InstanceURL string
- // Name of the instance to present to the receiver.
- InstanceName string
- // Link to present to the receiver to click on and begin the reset process.
- // Should be a full link with protocol eg., https://example.org/reset_password?token=some-reset-password-token
- ResetLink string
+ if err := smtp.SendMail(s.hostAddress, s.auth, s.from, []string{toAddress}, msg); err != nil {
+ return gtserror.SetType(err, gtserror.TypeSMTP)
+ }
+
+ return nil
}