Skip to content

Commit dedb2dd

Browse files
committed
fix(organizations): offer no Invite in a personal organization, whose invitations the server refuses
1 parent d5aac31 commit dedb2dd

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎apps/sim/lib/organizations/surface.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,20 @@ describe('getOrganizationSurfaceContext', () => {
207207
}
208208
)
209209

210+
it('offers no Invite to the owner of a personal organization, which the server refuses', async () => {
211+
queueTableRows(member, [{ role: 'owner' }])
212+
queueTableRows(organization, [
213+
{ id: 'org-1', name: 'Ada', slug: 'ada', logo: null, kind: 'personal' },
214+
])
215+
queueTableRows(member, [{ memberCount: 1 }])
216+
setEnvFlags({ isInvitationsDisabled: false, isInvitationUiDisabled: false })
217+
mockPermissionConfig.mockResolvedValue(DEFAULT_PERMISSION_GROUP_CONFIG)
218+
219+
await expect(getOrganizationSurfaceContext('org-1', 'viewer')).resolves.toMatchObject({
220+
viewer: { isAdmin: true, canInviteMembers: false },
221+
})
222+
})
223+
210224
it.each([
211225
{ disablePersonalApiKeys: false, disableOAuthAppAccess: false, allowed: true },
212226
{ disablePersonalApiKeys: true, disableOAuthAppAccess: false, allowed: false },

‎apps/sim/lib/organizations/surface.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ async function resolveOrganizationSurfaceGate(
117117
userId,
118118
role: access.role,
119119
isAdmin: access.isAdmin,
120+
/** A personal organization holds only its owner; the server refuses its invitations. */
120121
canInviteMembers:
121122
access.isAdmin &&
123+
row.kind !== 'personal' &&
122124
!deployment.invitationsDisabled &&
123125
!capabilityDeniedBy('invitations.send', config),
124126
canConnectSearchIntegrations: canConnectSearchIntegrations(config),

0 commit comments

Comments
 (0)