From 5f24c9d20f2d8e5e840d985bc401278600ccb8d1 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 19 Sep 2022 20:31:28 +0800 Subject: [PATCH 1/2] Fix bug --- models/user/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/user/user.go b/models/user/user.go index 490e7223ce638..1e731926cfa27 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -1265,7 +1265,7 @@ func isUserVisibleToViewerCond(viewer *User) builder.Cond { // IsUserVisibleToViewer check if viewer is able to see user profile func IsUserVisibleToViewer(ctx context.Context, u, viewer *User) bool { - if viewer != nil && viewer.IsAdmin { + if viewer != nil && (viewer.IsAdmin || viewer.ID == u.ID) { return true } From 966e18572e1eb0a6f1e1bcb0534e26060e2eee79 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 20 Sep 2022 09:31:01 +0800 Subject: [PATCH 2/2] More fix --- models/user/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/user/user.go b/models/user/user.go index 1e731926cfa27..a96232e386145 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -1304,7 +1304,7 @@ func IsUserVisibleToViewer(ctx context.Context, u, viewer *User) bool { return false } - if count < 0 { + if count == 0 { // No common organization return false }