diff --git a/pkg/user/notifications.go b/pkg/user/notifications.go index 741b43dd4..b3c2b4c46 100644 --- a/pkg/user/notifications.go +++ b/pkg/user/notifications.go @@ -72,3 +72,23 @@ func (n *PasswordChangedNotification) ToMail() *notifications.Mail { func (n *PasswordChangedNotification) ToDB() interface{} { return nil } + +// ResetPasswordNotification represents a ResetPasswordNotification notification +type ResetPasswordNotification struct { + User *User +} + +// ToMail returns the mail notification for ResetPasswordNotification +func (n *ResetPasswordNotification) ToMail() *notifications.Mail { + return notifications.NewMail(). + Subject("Reset your password on Vikunja"). + Greeting("Hi "+n.User.GetName()+","). + Line("To reset your password, click the link below:"). + Action("Reset your password", config.ServiceFrontendurl.GetString()+"?userPasswordReset="+n.User.PasswordResetToken). + Line("Have a nice day!") +} + +// ToDB returns the ResetPasswordNotification notification in a format which can be saved in the db +func (n *ResetPasswordNotification) ToDB() interface{} { + return nil +} diff --git a/pkg/user/user_password_reset.go b/pkg/user/user_password_reset.go index 6339fc889..4860e549a 100644 --- a/pkg/user/user_password_reset.go +++ b/pkg/user/user_password_reset.go @@ -18,7 +18,6 @@ package user import ( "code.vikunja.io/api/pkg/config" - "code.vikunja.io/api/pkg/mail" "code.vikunja.io/api/pkg/notifications" "code.vikunja.io/api/pkg/utils" "xorm.io/xorm" @@ -125,11 +124,10 @@ func RequestUserPasswordResetToken(s *xorm.Session, user *User) (err error) { return } - data := map[string]interface{}{ - "User": user, + n := &ResetPasswordNotification{ + User: user, } - // Send the user a mail with the reset token - mail.SendMailWithTemplate(user.Email, "Reset your password on Vikunja", "reset-password", data) + err = notifications.Notify(user, n) return } diff --git a/templates/mail/reset-password.html.tmpl b/templates/mail/reset-password.html.tmpl deleted file mode 100644 index e0dea5a95..000000000 --- a/templates/mail/reset-password.html.tmpl +++ /dev/null @@ -1,14 +0,0 @@ -{{template "mail-header.tmpl" .}} -

- Hi {{.User.Username}},
-
- To reset your password, click the link below: -

- - Reset your password - -

- If the button above doesn't work, copy the url below and paste it in your browsers address bar:
- {{.FrontendURL}}?userPasswordReset={{.User.PasswordResetToken}} -

-{{template "mail-footer.tmpl"}} \ No newline at end of file diff --git a/templates/mail/reset-password.plain.tmpl b/templates/mail/reset-password.plain.tmpl deleted file mode 100644 index 83a46c40a..000000000 --- a/templates/mail/reset-password.plain.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -Hi {{.User.Username}}, - -Use the following link to reset your password: {{.FrontendURL}}?userPasswordReset={{.User.PasswordResetToken}} \ No newline at end of file