From 6706ac2a0f5f2fe4f8e2555be7e2a8b4d5946398 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 28 Mar 2023 05:27:32 +0800 Subject: Fix profile page email display, respect settings (#23747) Always respect the `setting.UI.ShowUserEmail` and `KeepEmailPrivate` setting. * It doesn't make sense to show user's own E-mail to themself. * Always hide the E-mail if KeepEmailPrivate=true, then the user could know how their profile page looks like for others. * Revert the `setting.UI.ShowUserEmail` change from #4981 . This setting is used to control the E-mail display, not only for the user list page. ps: the incorrect `
` tag on the profile page has been fixed by #23748 together, so this PR becomes simpler. --- routers/web/user/profile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'routers') diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index f4d458c040..d690fa4d01 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -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) } -- cgit v1.2.3