Do not allow Ghost access to limited visible user/org (#21849) (#21875)

Backport of #21849

Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
KN4CK3R 2022-11-20 13:35:26 +01:00 committed by GitHub
parent 56716f5834
commit 87630a6583
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -448,8 +448,9 @@ func CountOrgs(opts FindOrgOptions) (int64, error) {
// HasOrgOrUserVisible tells if the given user can see the given org or user
func HasOrgOrUserVisible(ctx context.Context, orgOrUser, user *user_model.User) bool {
// Not SignedUser
if user == nil {
// If user is nil, it's an anonymous user/request.
// The Ghost user is handled like an anonymous user.
if user == nil || user.IsGhost() {
return orgOrUser.Visibility == structs.VisibleTypePublic
}