From a251a9808ae67c874ab5f7cb764a22727795e629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Tue, 1 Jul 2025 17:16:52 +0100 Subject: [PATCH] fix: private projects visibility for users in editor and admin groups (#10265) https://linear.app/unleash/issue/2-3665/viewer-role-in-admin-group-cannot-access-private-projects Fixes a bug where private projects were not visible for viewers that belonged to Editor or Admin groups. --- .../private-project/privateProjectStore.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib/features/private-project/privateProjectStore.ts b/src/lib/features/private-project/privateProjectStore.ts index deea882dfa..6dbe511c40 100644 --- a/src/lib/features/private-project/privateProjectStore.ts +++ b/src/lib/features/private-project/privateProjectStore.ts @@ -39,6 +39,20 @@ class PrivateProjectStore implements IPrivateProjectStore { 'roles.name': 'Viewer', 'roles.type': 'root', }) + .whereNotExists((builder) => { + builder + .select('*') + .from('group_user') + .join('groups', 'group_user.group_id', 'groups.id') + .join( + 'roles as group_roles', + 'groups.root_role_id', + 'group_roles.id', + ) + .whereRaw('group_user.user_id = role_user.user_id') + .whereIn('group_roles.name', ['Admin', 'Editor']) + .andWhere('group_roles.type', 'root'); + }) .count('*') .then((res) => Number(res[0].count));