Skip to content

Commit c2a1a03

Browse files
committed
Show email if the authenticated user owns the profile page being
requested for. Also removed `setting.UI.ShowUserEmail` as it's documentation says it only controls the email setting on the explore page
1 parent 7c0c965 commit c2a1a03

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

routers/user/profile.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ func Profile(ctx *context.Context) {
235235
}
236236
}
237237

238-
ctx.Data["ShowUserEmail"] = setting.UI.ShowUserEmail
238+
ctx.Data["ShowUserEmail"] = (len(ctxUser.Email) > 0 && ctx.IsSigned && !ctxUser.KeepEmailPrivate) ||
239+
ctxUser.ID == ctx.User.ID // Show email if the authenticated user owns the profile being viewed
239240

240241
ctx.HTML(200, tplProfile)
241242
}

templates/user/profile.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
{{if .Owner.Location}}
2323
<li><i class="octicon octicon-location"></i> {{.Owner.Location}}</li>
2424
{{end}}
25-
{{if and $.ShowUserEmail .Owner.Email .IsSigned (not .Owner.KeepEmailPrivate)}}
25+
{{if .ShowUserEmail }}
2626
<li>
2727
<i class="octicon octicon-mail"></i>
2828
<a href="mailto:{{.Owner.Email}}" rel="nofollow">{{.Owner.Email}}</a>

0 commit comments

Comments
 (0)