Move user password reset to notification
This commit is contained in:
parent
b6b960d154
commit
773f708d3a
|
@ -72,3 +72,23 @@ func (n *PasswordChangedNotification) ToMail() *notifications.Mail {
|
||||||
func (n *PasswordChangedNotification) ToDB() interface{} {
|
func (n *PasswordChangedNotification) ToDB() interface{} {
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.vikunja.io/api/pkg/config"
|
"code.vikunja.io/api/pkg/config"
|
||||||
"code.vikunja.io/api/pkg/mail"
|
|
||||||
"code.vikunja.io/api/pkg/notifications"
|
"code.vikunja.io/api/pkg/notifications"
|
||||||
"code.vikunja.io/api/pkg/utils"
|
"code.vikunja.io/api/pkg/utils"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -125,11 +124,10 @@ func RequestUserPasswordResetToken(s *xorm.Session, user *User) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data := map[string]interface{}{
|
n := &ResetPasswordNotification{
|
||||||
"User": user,
|
User: user,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the user a mail with the reset token
|
err = notifications.Notify(user, n)
|
||||||
mail.SendMailWithTemplate(user.Email, "Reset your password on Vikunja", "reset-password", data)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
{{template "mail-header.tmpl" .}}
|
|
||||||
<p>
|
|
||||||
Hi {{.User.Username}},<br>
|
|
||||||
<br>
|
|
||||||
To reset your password, click the link below:
|
|
||||||
</p>
|
|
||||||
<a href="{{.FrontendURL}}?userPasswordReset={{.User.PasswordResetToken}}" title="Reset your password" style="-webkit-box-shadow: 0.3em 0.3em 1em #b2d0ff; box-shadow: 0.3em 0.3em 1em #b2d0ff; background-color: #1973ff; border-color: transparent; color: #fff; text-decoration: none; text-align: center; text-rendering: optimizelegibility; text-transform: uppercase; font-weight: bold; font-size: 14px; padding: 10px 14px; margin: 10px auto; border-radius: 4px; user-select: none; display: block; width: 280px;font-family:sans-serif">
|
|
||||||
Reset your password
|
|
||||||
</a>
|
|
||||||
<p>
|
|
||||||
If the button above doesn't work, copy the url below and paste it in your browsers address bar:<br/>
|
|
||||||
{{.FrontendURL}}?userPasswordReset={{.User.PasswordResetToken}}
|
|
||||||
</p>
|
|
||||||
{{template "mail-footer.tmpl"}}
|
|
|
@ -1,3 +0,0 @@
|
||||||
Hi {{.User.Username}},
|
|
||||||
|
|
||||||
Use the following link to reset your password: {{.FrontendURL}}?userPasswordReset={{.User.PasswordResetToken}}
|
|
Loading…
Reference in New Issue