Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix profile page email display, respect settings #23747

Merged
merged 4 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion routers/web/user/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func Profile(ctx *context.Context) {
ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled

ctx.Data["ShowUserEmail"] = len(ctx.ContextUser.Email) > 0 && ctx.IsSigned && (!ctx.ContextUser.KeepEmailPrivate || ctx.ContextUser.ID == ctx.Doer.ID)
ctx.Data["ShowUserEmail"] = setting.UI.ShowUserEmail && ctx.ContextUser.Email != "" && ctx.IsSigned && !ctx.ContextUser.KeepEmailPrivate

ctx.HTML(http.StatusOK, tplProfile)
}
Expand Down
2 changes: 1 addition & 1 deletion templates/user/profile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="ui stackable grid">
<div class="ui five wide column">
<div class="ui card">
<div id="profile-avatar" class="content gt-df"/>
<div id="profile-avatar" class="content gt-df">
{{if eq .SignedUserName .Owner.Name}}
<a class="image" href="{{AppSubUrl}}/user/settings" data-tooltip-content="{{.locale.Tr "user.change_avatar"}}">
{{avatar $.Context .Owner 290}}
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/setting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func TestSettingShowUserEmailProfile(t *testing.T) {
req = NewRequest(t, "GET", "/user2")
resp = session.MakeRequest(t, req, http.StatusOK)
htmlDoc = NewHTMLParser(t, resp.Body)
// Should contain since this user owns the profile page
assert.Contains(t,
// Should not contain even if the user visits their own profile page
assert.NotContains(t,
htmlDoc.doc.Find(".user.profile").Text(),
"user2@example.com",
)
Expand Down