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

Show email if the authenticated user owns the profile page being requested for #4981

Merged
merged 12 commits into from
Feb 19, 2019
Prev Previous commit
Next Next commit
fix current user check... This prevents a panic as a user must be sig…
…ned in before ctx.User is called
adelowo committed Dec 9, 2018

Unverified

This user has not yet uploaded their public signing key.
commit 9368cfcdd6b5ecfaadee8a8730d310ce1cbf906a
13 changes: 11 additions & 2 deletions routers/user/profile.go
Original file line number Diff line number Diff line change
@@ -235,8 +235,17 @@ func Profile(ctx *context.Context) {
}
}

ctx.Data["ShowUserEmail"] = (len(ctxUser.Email) > 0 && ctx.IsSigned && !ctxUser.KeepEmailPrivate) ||
ctxUser.ID == ctx.User.ID // Show email if the authenticated user owns the profile being viewed
var showEmail bool

if len(ctxUser.Email) > 0 && ctx.IsSigned && !ctxUser.KeepEmailPrivate {
showEmail = true
} else if ctx.IsSigned {
// Show email if the authenticated user owns the profile
// being viewed
showEmail = ctxUser.ID == ctx.User.ID
}

ctx.Data["ShowUserEmail"] = showEmail

ctx.HTML(200, tplProfile)
}