summaryrefslogtreecommitdiffstats
path: root/models/mail.go
diff options
context:
space:
mode:
authormrsdizzie <info@mrsdizzie.com>2019-04-04 03:52:48 -0400
committerLauris BH <lauris@nix.lv>2019-04-04 10:52:48 +0300
commit04003d9dc7f79bf1ce6eb30db50d9f41d85d362f (patch)
treeb053a1f5f924914cc7dccb4a5f054b71f94dd691 /models/mail.go
parent3f4e2d9d376b553ee931e1539174372ed550dd27 (diff)
downloadgitea-04003d9dc7f79bf1ce6eb30db50d9f41d85d362f.tar.gz
gitea-04003d9dc7f79bf1ce6eb30db50d9f41d85d362f.zip
Make distinction between DisplayName and Username in email templates (#6495)
* Make distinction between DisplayName and Username in email templates Store the actual username in the variable named Username and store the separate DisplayName in another variable. This allows us to access the actual username when we need, which currently fails if a user has set a full name. Fixes #6161 * Use u.Name directly No need for extra function, also change use in all mail sending functions here * Don't include Username when not used
Diffstat (limited to 'models/mail.go')
-rw-r--r--models/mail.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/models/mail.go b/models/mail.go
index 31ac4a3a5a..4f2bd548f7 100644
--- a/models/mail.go
+++ b/models/mail.go
@@ -47,7 +47,7 @@ func SendTestMail(email string) error {
// SendUserMail sends a mail to the user
func SendUserMail(c *macaron.Context, u *User, tpl base.TplName, code, subject, info string) {
data := map[string]interface{}{
- "Username": u.DisplayName(),
+ "DisplayName": u.DisplayName(),
"ActiveCodeLives": base.MinutesToFriendly(setting.Service.ActiveCodeLives, c.Locale.Language()),
"ResetPwdCodeLives": base.MinutesToFriendly(setting.Service.ResetPwdCodeLives, c.Locale.Language()),
"Code": code,
@@ -79,7 +79,7 @@ func SendResetPasswordMail(c *macaron.Context, u *User) {
// SendActivateEmailMail sends confirmation email to confirm new email address
func SendActivateEmailMail(c *macaron.Context, u *User, email *EmailAddress) {
data := map[string]interface{}{
- "Username": u.DisplayName(),
+ "DisplayName": u.DisplayName(),
"ActiveCodeLives": base.MinutesToFriendly(setting.Service.ActiveCodeLives, c.Locale.Language()),
"Code": u.GenerateEmailActivateCode(email.Email),
"Email": email.Email,
@@ -101,7 +101,8 @@ func SendActivateEmailMail(c *macaron.Context, u *User, email *EmailAddress) {
// SendRegisterNotifyMail triggers a notify e-mail by admin created a account.
func SendRegisterNotifyMail(c *macaron.Context, u *User) {
data := map[string]interface{}{
- "Username": u.DisplayName(),
+ "DisplayName": u.DisplayName(),
+ "Username": u.Name,
}
var content bytes.Buffer