Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/33758-hide-resend-invitation-cloud-managed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@objectstack/platform-objects': patch
'@objectstack/spec': patch
---

Clause-②: no
Metadata-protocol: none

Setup → Invitations no longer offers **Resend Invitation** on a cloud-managed environment. A resend is a call to invite-member, which a cloud-managed environment refuses with `409 RESOURCE_CONFLICT`, so the action now carries the same `features.cloudManaged != true` gate as the four Invite User mirrors and Copy Invite Link, and is booked in `PUBLIC_AUTH_FEATURES.cloudManaged.gatedInputs`. Off a managed environment it is offered exactly as before.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* its people arrive from the organisation's identity provider. Six actions are
* hidden while the flag is on — the four `invite_user` mirrors, `create_user`
* and `set_user_password` — and each is offered as before when the flag is
* off (ruling 6341690661 on #25083, Q3 A and Q4 A).
* off (ruling 6341690661 on #25083, Q3 A and Q4 A). `resend_invitation`
* rides the invite mirrors' door, so it is hidden the same way (its own
* block below).
*
* Not pinned here: a payload that omits the flag. plugin-auth's drift guard
* holds the served boolean key set stable, and this engine faults on ANY
Expand Down Expand Up @@ -76,6 +78,42 @@ describe('features.cloudManaged hides the six doors that add people', () => {
});
});

/**
* `sys_invitation.resend_invitation` is not a door that adds a person, so it
* is not among the six above, but it rides the same door: a resend IS a call
* to invite-member, which a cloud-managed environment refuses (`409
* RESOURCE_CONFLICT`, resends included). So it carries the same gate as the
* invite mirrors: hidden while managed, offered as before on a pending row
* (unexpired or past its `expires_at`) when the flag is off.
*/
describe('features.cloudManaged hides Resend Invitation, whose door it refuses', () => {
const resendOffered = (record: Record<string, unknown>, features: Record<string, unknown>): boolean | string => {
const r = celEngine.evaluate(
{ dialect: 'cel', source: visibleOf(SysInvitation, 'resend_invitation') },
{ record, extra: { current_user: ADMIN, user: ADMIN, ctx: { user: ADMIN }, features } },
);
if (!r.ok) return `FAULT ${r.error.message.split('\n')[0].trim()}`;
return typeof r.value === 'boolean' ? r.value : `NON-BOOLEAN ${JSON.stringify(r.value)}`;
};
const DAY_MS = 24 * 60 * 60 * 1000;
const ROWS: ReadonlyArray<[string, Record<string, unknown>]> = [
['an unexpired pending row', { id: 'inv_1', status: 'pending', email: 'b@example.com', role: 'member', expires_at: new Date(Date.now() + DAY_MS).toISOString() }],
['a pending row past its expires_at', { id: 'inv_1', status: 'pending', email: 'b@example.com', role: 'member', expires_at: new Date(Date.now() - DAY_MS).toISOString() }],
];

it.each(ROWS)('is hidden on %s while the environment is cloud-managed', (_row, record) => {
expect(resendOffered(record, { ...OTHER_FLAGS, cloudManaged: true })).toBe(false);
});

it.each(ROWS)('is offered on %s as before when the flag is off', (_row, record) => {
expect(resendOffered(record, { ...OTHER_FLAGS, cloudManaged: false })).toBe(true);
});

it('keeps its organization gate: off hides it whatever cloudManaged says', () => {
expect(resendOffered(ROWS[0][1], { organization: false, admin: true, cloudManaged: false })).toBe(false);
});
});

/**
* The managed counterparts (cloud#4465 child 1b): `add_sso_user` and
* `import_sso_users` add a PENDING person through plugin-auth's
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ export const SysInvitation = ObjectSchema.create({
type: 'api',
target: '/api/v1/auth/organization/invite-member',
bodyExtra: { resend: true },
// Hidden while cloud-managed, as the four invite mirrors and
// `copy_invitation_link` are: a resend IS a call to invite-member,
// which a managed environment refuses outright (409, resends
// included — plugin-auth's `auth-manager-before-hook.ts`).
visible: 'features.cloudManaged != true',
requiresFeature: 'organization',
// A resend IS a call to invite-member, so it is reached by the grades
// that reach that endpoint — delegated_admin included.
Expand Down
2 changes: 1 addition & 1 deletion packages/platform-objects/src/platform-objects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ describe('feature-gate lowering matrix (#2874)', () => {
['SysMember', SysMember, 'transfer_ownership', `((has(record.role) && record.role != 'owner') && ${OWNER}) && ${ORG}`],
['SysInvitation', SysInvitation, 'invite_user', `((${MANAGED}) && ${INVITE}) && ${ORG}`],
['SysInvitation', SysInvitation, 'cancel_invitation', `${ADMINS} && ${ORG}`],
['SysInvitation', SysInvitation, 'resend_invitation', `${INVITE} && ${ORG}`],
['SysInvitation', SysInvitation, 'resend_invitation', `((${MANAGED}) && ${INVITE}) && ${ORG}`],
['SysTeam', SysTeam, 'create_team', `${ADMINS} && ${ORG}`],
['SysTeam', SysTeam, 'update_team', `${ADMINS} && ${ORG}`],
['SysTeam', SysTeam, 'remove_team', `${ADMINS} && ${ORG}`],
Expand Down
2 changes: 2 additions & 0 deletions packages/spec/src/kernel/public-auth-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ export const PUBLIC_AUTH_FEATURES = {
'sys_member.actions.invite_user',
'sys_invitation.actions.invite_user',
'sys_organization.actions.invite_user',
// A resend is a call to invite-member, which refuses it here.
'sys_invitation.actions.resend_invitation',
// [#27843] The invitation's accept link: no invitation is handed out here.
'sys_invitation.actions.copy_invitation_link',
'sys_user.actions.create_user',
Expand Down
Loading