Add reset password, fix #58
This commit is contained in:
parent
3ebc9b991a
commit
b7c3b0cc73
10 changed files with 214 additions and 29 deletions
|
@ -67,6 +67,10 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{
|
|||
"DateFormat": DateFormat,
|
||||
"List": List,
|
||||
"Mail2Domain": func(mail string) string {
|
||||
if !strings.Contains(mail, "@") {
|
||||
return "try.gogits.org"
|
||||
}
|
||||
|
||||
suffix := strings.SplitN(mail, "@", 2)[1]
|
||||
domain, ok := mailDomains[suffix]
|
||||
if !ok {
|
||||
|
|
|
@ -86,7 +86,27 @@ func SendActiveMail(r *middleware.Render, user *models.User) {
|
|||
}
|
||||
|
||||
msg := NewMailMessage([]string{user.Email}, subject, body)
|
||||
msg.Info = fmt.Sprintf("UID: %d, send email verify mail", user.Id)
|
||||
msg.Info = fmt.Sprintf("UID: %d, send active mail", user.Id)
|
||||
|
||||
SendAsync(&msg)
|
||||
}
|
||||
|
||||
// Send reset password email.
|
||||
func SendResetPasswdMail(r *middleware.Render, user *models.User) {
|
||||
code := CreateUserActiveCode(user, nil)
|
||||
|
||||
subject := "Reset your password"
|
||||
|
||||
data := GetMailTmplData(user)
|
||||
data["Code"] = code
|
||||
body, err := r.HTMLString("mail/auth/reset_passwd", data)
|
||||
if err != nil {
|
||||
log.Error("mail.SendResetPasswdMail(fail to render): %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
msg := NewMailMessage([]string{user.Email}, subject, body)
|
||||
msg.Info = fmt.Sprintf("UID: %d, send reset password email", user.Id)
|
||||
|
||||
SendAsync(&msg)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue