diff options
author | Unknown <joe2010xtmf@163.com> | 2014-04-05 12:32:34 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-04-05 12:32:34 -0400 |
commit | b7c3b0cc73ad8721e2eec59d018a91850ba7f750 (patch) | |
tree | dd0bea39e518efe4c56f19397c0f583d98a6732c /modules | |
parent | 3ebc9b991a70e10c4b2c6319c1ff6195c0d75a17 (diff) |
Add reset password, fix #58
Diffstat (limited to 'modules')
-rw-r--r-- | modules/base/template.go | 4 | ||||
-rw-r--r-- | modules/mailer/mail.go | 22 |
2 files changed, 25 insertions, 1 deletions
diff --git a/modules/base/template.go b/modules/base/template.go index dfcae931..56b77a5d 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -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 { diff --git a/modules/mailer/mail.go b/modules/mailer/mail.go index b99fc8fd..eee6b916 100644 --- a/modules/mailer/mail.go +++ b/modules/mailer/mail.go @@ -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) } |