Skip to content

Commit 9368cfc

Browse files
committed
fix current user check... This prevents a panic as a user must be signed in before ctx.User is called
1 parent c2a1a03 commit 9368cfc

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

routers/user/profile.go

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

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
238+
var showEmail bool
239+
240+
if len(ctxUser.Email) > 0 && ctx.IsSigned && !ctxUser.KeepEmailPrivate {
241+
showEmail = true
242+
} else if ctx.IsSigned {
243+
// Show email if the authenticated user owns the profile
244+
// being viewed
245+
showEmail = ctxUser.ID == ctx.User.ID
246+
}
247+
248+
ctx.Data["ShowUserEmail"] = showEmail
240249

241250
ctx.HTML(200, tplProfile)
242251
}

0 commit comments

Comments
 (0)