Skip to content

Commit 04003d9

Browse files
mrsdizzielafriks
authored andcommitted
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
1 parent 3f4e2d9 commit 04003d9

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

models/mail.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func SendTestMail(email string) error {
4747
// SendUserMail sends a mail to the user
4848
func SendUserMail(c *macaron.Context, u *User, tpl base.TplName, code, subject, info string) {
4949
data := map[string]interface{}{
50-
"Username": u.DisplayName(),
50+
"DisplayName": u.DisplayName(),
5151
"ActiveCodeLives": base.MinutesToFriendly(setting.Service.ActiveCodeLives, c.Locale.Language()),
5252
"ResetPwdCodeLives": base.MinutesToFriendly(setting.Service.ResetPwdCodeLives, c.Locale.Language()),
5353
"Code": code,
@@ -79,7 +79,7 @@ func SendResetPasswordMail(c *macaron.Context, u *User) {
7979
// SendActivateEmailMail sends confirmation email to confirm new email address
8080
func SendActivateEmailMail(c *macaron.Context, u *User, email *EmailAddress) {
8181
data := map[string]interface{}{
82-
"Username": u.DisplayName(),
82+
"DisplayName": u.DisplayName(),
8383
"ActiveCodeLives": base.MinutesToFriendly(setting.Service.ActiveCodeLives, c.Locale.Language()),
8484
"Code": u.GenerateEmailActivateCode(email.Email),
8585
"Email": email.Email,
@@ -101,7 +101,8 @@ func SendActivateEmailMail(c *macaron.Context, u *User, email *EmailAddress) {
101101
// SendRegisterNotifyMail triggers a notify e-mail by admin created a account.
102102
func SendRegisterNotifyMail(c *macaron.Context, u *User) {
103103
data := map[string]interface{}{
104-
"Username": u.DisplayName(),
104+
"DisplayName": u.DisplayName(),
105+
"Username": u.Name,
105106
}
106107

107108
var content bytes.Buffer

templates/mail/auth/activate.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<html>
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5-
<title>{{.Username}}, please activate your account</title>
5+
<title>{{.DisplayName}}, please activate your account</title>
66
</head>
77

88
<body>
9-
<p>Hi <b>{{.Username}}</b>, thanks for registering at {{AppName}}!</p>
9+
<p>Hi <b>{{.DisplayName}}</b>, thanks for registering at {{AppName}}!</p>
1010
<p>Please click the following link to activate your account within <b>{{.ActiveCodeLives}}</b>:</p>
1111
<p><a href="{{AppUrl}}user/activate?code={{.Code}}">{{AppUrl}}user/activate?code={{.Code}}</a></p>
1212
<p>Not working? Try copying and pasting it to your browser.</p>

templates/mail/auth/activate_email.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<html>
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5-
<title>{{.Username}}, please verify your e-mail address</title>
5+
<title>{{.DisplayName}}, please verify your e-mail address</title>
66
</head>
77

88
<body>
9-
<p>Hi <b>{{.Username}}</b>,</p>
9+
<p>Hi <b>{{.DisplayName}}</b>,</p>
1010
<p>Please click the following link to verify your email address within <b>{{.ActiveCodeLives}}</b>:</p>
1111
<p><a href="{{AppUrl}}user/activate_email?code={{.Code}}&email={{.Email}}">{{AppUrl}}user/activate_email?code={{.Code}}&email={{.Email}}</a></p>
1212
<p>Not working? Try copying and pasting it to your browser.</p>

templates/mail/auth/register_notify.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<html>
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5-
<title>{{.Username}}, welcome to {{AppName}}</title>
5+
<title>{{.DisplayName}}, welcome to {{AppName}}</title>
66
</head>
77

88
<body>
9-
<p>Hi <b>{{.Username}}</b>, this is your registration confirmation email for {{AppName}}!</p>
9+
<p>Hi <b>{{.DisplayName}}</b>, this is your registration confirmation email for {{AppName}}!</p>
1010
<p>You can now login via username: {{.Username}}.</p>
1111
<p><a href="{{AppUrl}}user/login">{{AppUrl}}user/login</a></p>
1212
<p>If this account has been created for you, please <a href="{{AppUrl}}user/forgot_password">reset your password</a> first.</p>

templates/mail/auth/reset_passwd.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<html>
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5-
<title>{{.Username}}, you have requested to reset your password</title>
5+
<title>{{.DisplayName}}, you have requested to reset your password</title>
66
</head>
77

88
<body>
9-
<p>Hi <b>{{.Username}}</b>,</p>
9+
<p>Hi <b>{{.DisplayName}}</b>,</p>
1010
<p>Please click the following link to reset your password within <b>{{.ResetPwdCodeLives}}</b>:</p>
1111
<p><a href="{{AppUrl}}user/reset_password?code={{.Code}}">{{AppUrl}}user/reset_password?code={{.Code}}</a></p>
1212
<p>Not working? Try copying and pasting it to your browser.</p>

0 commit comments

Comments
 (0)