Skip to content

Commit e2a4c66

Browse files
fix(auth)!: a cloud-managed environment refuses remove-member and update-member-role (#34281)
Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — no skill under `skills/**` teaches the organization membership doors or the cloud-managed mode; `content/docs/permissions/authentication.mdx` gains the rule in this change. ## 维护者速读 - **改了什么**:云托管环境(`OS_CLOUD_MANAGED=1`)上,成员资格与成员等级由托管该环境的组织管理:组织族中凡写入或删除成员行的六扇门一律答 `409 RESOURCE_CONFLICT` 且不写任何东西(与邀请成员同一信封):移除成员、修改成员等级(含「设为所有者」)、离开组织、接受邀请、创建组织(创建者成为所有者)、删除组织(结束其全部成员资格);对应的七个操作在云托管时隐藏。唯一例外:`add-member` 只接纳平台管理员、只做「添加一条成员资格」,用于恢复环境丢失的成员资格。 - **为什么改**:成员资格归托管组织所有,是已有邀请规则的同一条规则;组织族其余路由不写成员行(团队、邀请、当前组织、组织自身字段)或只读,照旧。自托管部署不受影响。 - **风险与回滚**:属破坏性变更(BREAKING),只影响云托管环境:在环境内移除成员、改等级、离开、接受邀请、创建或删除组织的人改到托管组织去做。回滚即还原本 PR。 - **先看**:① `packages/plugins/plugin-auth/src/auth-manager-before-hook.ts`(`CLOUD_MANAGED_MEMBERSHIP_DOORS` 六条与拒绝分支的位置:在 remove-member 权限分支、组织删除记录分支与改等级授权快照之前);② `packages/plugins/plugin-auth/src/cloud-managed.ts`(族普查与六句拒绝文案);③ `packages/platform-objects/src/identity/`(七个 `visible`)。 - **两分钟验证**:`pnpm --filter @objectstack/plugin-auth exec vitest run src/cloud-managed.test.ts`,预期全部通过:云托管下六扇门各答 409 且成员行不变,自托管下各照常 200 并改动成员行,非平台管理员调用 `add-member` 得 403。 - **需要你做的**:无,席位落地 ## What changes The rule: **on a cloud-managed environment, membership and membership tiers are managed by the organisation that hosts it.** It extends the invite-member rule already in place. Every organization-family door that writes or deletes an organization membership row refuses; `add-member` alone stays open. - **plugin-auth: six doors refused.** On a cloud-managed environment, each door below refuses every request with the envelope `invite-member` already gives (`409 RESOURCE_CONFLICT`) and writes nothing. `CLOUD_MANAGED_MEMBERSHIP_DOORS` in `auth-manager-before-hook.ts` lists them, and the refusal comes ahead of the remove-member permission arm, the organization-delete records arm and the role-change grant read, so none of them runs on a refused request. Six sentences join `CLOUD_MANAGED_REFUSAL_MESSAGES`: `removeMember`, `updateMemberRole`, `leaveOrganization`, `acceptInvitation`, `createOrganization`, `deleteOrganization`. This hook is the only line of refusal: no in-process caller reaches these vendor operations. The hook comment says so, and says that a future in-process caller needs its own refusal. - **platform-objects: seven actions hidden.** `features.cloudManaged != true` now sits in `visible` on `sys_member.update_member_role`, `remove_member` and `transfer_ownership`; `sys_organization.leave_organization`, `create_organization` and `delete_organization`; and `sys_invitation.accept_invitation`. The invite actions are already hidden the same way. - **spec.** `PUBLIC_AUTH_FEATURES.cloudManaged.gatedInputs` books the seven paths. The registry note now names `accept_invitation` as the one gated input that has no second feature gate. This is a list entry, not a schema change, so `Metadata-protocol: none`. - **The one exception.** `POST /organization/add-member` admits exactly a platform administrator, adding a membership. On a managed environment it restores a membership the environment lost; any other caller is refused `403 PERMISSION_DENIED` (pinned). - **Self-hosted** deployments never set the switch and answer exactly as before. - **Docs.** `content/docs/permissions/authentication.mdx` states the rule in its cloud-managed section: the six doors, the seven hidden actions, what add-member admits, and that the rest of the family is unchanged. The six routes sit in a marked wire fence. - **A membership pin.** `membership-required-every-posture.dogfood.test.ts` gains a leg under each tenancy posture. A person whose membership row was deleted under the system context (no door) signs in to no active organization, adopts no membership, and cannot read or write any of the organization's data, their own note included. ### The organization family on a cloud-managed environment Every `family: 'organization'` route in `auth-route-ledger.ts` (26 routes): | Route | Disposition | Reason | | --- | --- | --- | | `POST /organization/remove-member` | refused (409) | deletes a membership row | | `POST /organization/update-member-role` | refused (409) | re-tiers a membership row (Make Owner included) | | `POST /organization/leave` | refused (409) | deletes the caller's membership row | | `POST /organization/accept-invitation` | refused (409) | creates a membership row | | `POST /organization/create` | refused (409) | creates the caller's owner membership row | | `POST /organization/delete` | refused (409) | deletes every membership row of the organization | | `POST /organization/add-member` | the exception | admits exactly a platform administrator, adding a membership | | `POST /organization/invite-member` | refused already (409) | invitation rows; refused before this change | | `POST /organization/cancel-invitation` | unchanged | invitation row only | | `POST /organization/reject-invitation` | unchanged | invitation row only (pinned: answers 200 when managed) | | `POST /organization/add-team-member` | out of scope | team rows only | | `POST /organization/remove-team-member` | out of scope | team rows only | | `POST /organization/create-team` | out of scope | team rows only | | `POST /organization/update-team` | out of scope | team row only | | `POST /organization/remove-team` | out of scope | team rows only | | `POST /organization/set-active` | unchanged | the session's active organization, no membership row | | `POST /organization/update` | unchanged | the organization's own fields | | `GET /organization/get-active-member` | unchanged | read | | `GET /organization/get-full-organization` | unchanged | read | | `GET /organization/list` | unchanged | read | | `GET /organization/list-members` | unchanged | read | | `GET /organization/list-invitations` | unchanged | read | | `GET /organization/list-user-invitations` | unchanged | read | | `GET /organization/list-teams` | unchanged | read | | `GET /organization/list-team-members` | unchanged | read | | `GET /organization/invitation-preview` | unchanged | read | ## Tests - `plugin-auth/src/cloud-managed.test.ts` gains one top-level `describe`. It runs on the real `AuthManager` behind the real route mount; create and delete run on a walled posture, since `single` refuses a second organization. - On a managed environment, each of the six doors is refused with the envelope (`code`, `status` and the door's own sentence), and the membership rows are unchanged. For create, no organization is written either; for delete, the organization stays. - The arms behind the refusal never run (spied): the permission judge, the grant read and the delete records judge. - CONTROLS on self-hosted: each door answers `200` and changes the rows (the spied arms run there). - add-member still answers a platform administrator on a managed environment and restores the row; an ordinary member is refused `403 PERMISSION_DENIED` there with nothing written. - invite-member keeps its own refusal, and reject-invitation answers `200` when managed. - `platform-objects`: - The feature-gate guard's forward rows now include the seven paths; the walker floor goes from 37 to 44. - The lowering matrix carries the new conjunct on the six action rows it already had, and adds an `accept_invitation` row. - `identity/cloud-managed-visibility.test.ts` evaluates the seven predicates through the canonical CEL engine. Each is hidden when managed, offered as before when not, and still hidden when its other gate is closed (organization or `multiOrgEnabled`; the pending row for accept). add-member stays offered when managed, and reject-invitation too. - The sparse-face sweep reads the new conjunct. ## Acceptance notes - The docs page carried the managed refusals for create-user and import-users, not invite-member; the rule went into that same cloud-managed section. - No skill under `skills/**` teaches these doors, so no skill moves. ## Verification Readings at head `852c9a0e942bfc395181fa9739dd889144632c35`, under the verify lock. <details><summary>Rule suites, ablations, gates and the dogfood battery</summary> - `pnpm --filter @objectstack/plugin-auth exec vitest run src/cloud-managed.test.ts`: Tests 59 passed (59). - platform-objects pins (`feature-gate-guard`, `identity/action-predicate-sparse-face`, `identity/cloud-managed-visibility`, `platform-objects`): Test Files 4 passed (4), Tests 353 passed (353). - `membership-required-every-posture.dogfood.test.ts`: Tests 21 passed (21). `org-change-slug-bound-action.dogfood.test.ts`: Tests 5 passed (5). - Typecheck: `@objectstack/plugin-auth`, `@objectstack/platform-objects` and `@objectstack/spec` each exit 0. - **Ablation of the refusal arm** (`scripts/ablation-replace.mjs`, WRAP on the membership-door arm of the before-hook): `src/cloud-managed.test.ts` Tests 10 failed | 49 passed (59), the reds being the refusal pins of the six doors and the refuse-ahead-of-the-arms pins. Restored: blob equal to HEAD, `git diff HEAD` empty. - **Ablation of the fixture correction** (the old cross-check put back): `org-change-slug-bound-action.dogfood.test.ts` 1 failed | 4 passed. Restored the same way. - `dispatch-gates --commands` ∪ `--ran`: 116 derived, 116 run, 0 NOT-MEASURED, 0 UNRUN; the three prerequisite gates were run after building their prerequisites (`check:skill-examples` 347 examples, `check:dual-build-cjs-loads` 123 entry points across 72 packages, `check:type-check-debt` OK). - **Dogfood battery** (`pnpm --filter @objectstack/dogfood test`, no shard, no path): Test Files 473 passed | 3 skipped (476), Tests 4006 passed | 42 skipped (4048), no failures. - CI at this head: 59 success, 12 skipped, 0 failed. </details> Round 3 changes from `dc93845f`: the dogfood cross-check of the multi-org gate now compares against `set_active_organization`, the one `sys_organization` action whose only gate is `multiOrgEnabled` (`leave_organization` now also carries the cloud-managed hide); the docs say who names the tier of a membership added through add-member and that a caller with no session is answered as unauthenticated; `origin/main` merged without conflict. --- _Generated by [Claude Code](https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f)_ <!-- signed: security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 329f2f7 commit e2a4c66

15 files changed

Lines changed: 608 additions & 22 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@objectstack/plugin-auth': patch
3+
'@objectstack/platform-objects': patch
4+
'@objectstack/spec': patch
5+
---
6+
7+
fix(auth)!: on a cloud-managed environment every organization door that writes or deletes a membership row refuses, add-member excepted; membership is managed by the hosting organisation
8+
9+
Clause-②: no (narrowing) — narrowed: on a cloud-managed environment only (`OS_CLOUD_MANAGED=1`), six organization doors that write or delete a membership row now answer `409 RESOURCE_CONFLICT` to every request and write nothing, where they changed membership: `POST /organization/remove-member`, `POST /organization/update-member-role` (Make Owner calls it), `POST /organization/leave`, `POST /organization/accept-invitation`, `POST /organization/create` (it made the caller the new organization's owner) and `POST /organization/delete` (it ended every membership of the organization). Six refusal sentences are added (`CLOUD_MANAGED_REFUSAL_MESSAGES.removeMember`, `.updateMemberRole`, `.leaveOrganization`, `.acceptInvitation`, `.createOrganization`, `.deleteOrganization`). Their seven actions are hidden while `features.cloudManaged` is on, as the invite actions are (`sys_member.update_member_role`, `remove_member`, `transfer_ownership`; `sys_organization.leave_organization`, `create_organization`, `delete_organization`; `sys_invitation.accept_invitation`), and `PUBLIC_AUTH_FEATURES.cloudManaged.gatedInputs` books the seven paths.
10+
Metadata-protocol: none
11+
Skills-docs: none — no skill under `skills/**` teaches the organization membership doors or the cloud-managed mode; `content/docs/permissions/authentication.mdx` gains the rule in this change.
12+
13+
<!-- adr-0087: not-required (no-migration-prescription) No schema key, accepted value or metadata type is added, removed, renamed or re-shaped: seven paths join a feature-flag registry list, and the moved answers are runtime refusals at six auth doors under a deployment switch that only hosted environments set, so there is nothing stored for a migration to rewrite and no tombstone. -->
14+
15+
**BREAKING** for a cloud-managed environment (`OS_CLOUD_MANAGED=1`, set only on hosted containers): membership and membership tiers are managed by the organisation that hosts the environment. Every organization door that writes or deletes a membership row refuses every request with `409 RESOURCE_CONFLICT` and writes nothing, as `POST /organization/invite-member` already did: Remove Member, Change Role and Make Owner, Leave Organization, Accept Invitation, Create Organization and Delete Organization. Their actions are hidden there.
16+
17+
Who moves: an owner (or administrator) of a cloud-managed environment who changed membership from inside the environment, and a member who left, accepted an invitation, or created or deleted an organization there. Make the change in the hosting organisation instead.
18+
19+
Unchanged: every self-hosted deployment (the variable unset), where every door answers as before; `POST /organization/add-member`, which on a managed environment admits exactly a platform administrator, adding a membership, to restore one the environment lost; and the organization doors that write no membership row (teams, invitations, the active organization, the organization's own fields) or only read.

‎content/docs/permissions/authentication.mdx‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,33 @@ sign-in through any other one leaves the person pending. Their positions, permis
13091309
from the moment they are added, so seed data and approval flows can name them
13101310
before they sign in. Off a managed environment both doors answer `409`.
13111311

1312+
On a cloud-managed environment the organisation that hosts it decides who is a
1313+
member and at which membership tier, so every organization door that writes or
1314+
deletes a membership row (the six below: removing a member, changing a member's tier
1315+
with Make Owner included, leaving, accepting an invitation, creating an
1316+
organization, which makes the caller its owner, and deleting one, which ends
1317+
every membership in it) answers `409 RESOURCE_CONFLICT` there and changes
1318+
nothing, and their seven actions are hidden. The one exception is
1319+
`POST /api/v1/auth/organization/add-member`, which admits exactly a platform
1320+
administrator, adding a membership, so the operator can restore one the
1321+
environment lost. The administrator names the membership tier in the request
1322+
body, where it is required (a request without it is refused `400`), and
1323+
ObjectStack passes it to better-auth unchanged. A signed-in caller who is not a platform
1324+
administrator is refused `403 PERMISSION_DENIED`, and a caller with no session
1325+
is answered `401 UNAUTHENTICATED`. The other
1326+
organization doors write no membership row (teams, invitations, the active
1327+
organization, the organization's own fields) or only read, and answer as before.
1328+
1329+
{/* os:vendor-wire better-auth */}
1330+
```http
1331+
POST /api/v1/auth/organization/remove-member
1332+
POST /api/v1/auth/organization/update-member-role
1333+
POST /api/v1/auth/organization/leave
1334+
POST /api/v1/auth/organization/accept-invitation
1335+
POST /api/v1/auth/organization/create
1336+
POST /api/v1/auth/organization/delete
1337+
```
1338+
13121339
Signing in does not lock the manager: a platform administrator still changes
13131340
it with **Set Manager** (`POST /api/v1/auth/admin/set-user-manager`). That
13141341
endpoint refuses only a person a SCIM directory holds, whose manager is changed

‎packages/platform-objects/src/feature-gate-guard.test.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,12 @@ describe('feature-gate completeness guard (#2874)', () => {
264264
}
265265

266266
it('finds the gated surface (guards the walker itself)', () => {
267-
// 37 booked inputs exist today (38 before #9968 retired
268-
// sys_user.actions.set_user_role); if the walker ever goes blind and
269-
// finds none, the it.each below would vacuously pass — pin a floor
270-
// instead.
271-
expect(referencedInputs.length).toBeGreaterThanOrEqual(37);
267+
// 44 booked inputs exist today (37 before the seven membership actions
268+
// were hidden while cloud-managed; 38 before #9968
269+
// retired sys_user.actions.set_user_role); if the walker ever goes
270+
// blind and finds none, the it.each below would vacuously pass — pin a
271+
// floor instead.
272+
expect(referencedInputs.length).toBeGreaterThanOrEqual(44);
272273
});
273274

274275
it.each(referencedInputs)('%s references registered flag %s and is booked', (path, flag) => {

‎packages/platform-objects/src/identity/action-predicate-sparse-face.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ function sourceOf(raw: unknown): string | undefined {
106106
const FEATURES = {
107107
organization: true, multiOrgEnabled: true, twoFactor: true,
108108
oidcProvider: true, admin: true, phoneNumber: true, apiKey: true, sso: true,
109+
// The one hide-when-on flag the swept actions read: off is its "on" here,
110+
// the setting that leaves the record half reachable.
111+
cloudManaged: false,
109112
};
110113

111114
/** Evaluate through the canonical engine; a fault is reported, never thrown. */

‎packages/platform-objects/src/identity/cloud-managed-visibility.test.ts‎

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,96 @@ describe('features.cloudManaged offers the two doors that add a pending person',
200200
expect(offeredSites).toEqual(SIX.map(([site]) => site));
201201
});
202202
});
203+
204+
/**
205+
* Membership and roles on a cloud-managed environment are managed by the
206+
* organisation that hosts it, so the three row actions that change them are
207+
* hidden while the flag is on: Change Role and Make Owner (both call
208+
* update-member-role) and Remove Member (remove-member), each of whose doors
209+
* refuses there. Each is offered as before when the flag is off. Add Member
210+
* stays offered to a platform administrator on a managed environment: its
211+
* door is the one left open, to restore a membership the environment lost.
212+
*/
213+
describe('features.cloudManaged hides the row actions that change a membership or its role', () => {
214+
const MEMBER_ROW = { id: 'mem_1', user_id: 'u_member', organization_id: 'org_1', role: 'member' };
215+
const THREE: ReadonlyArray<[string]> = [['update_member_role'], ['remove_member'], ['transfer_ownership']];
216+
217+
const rowOffered = (name: string, features: Record<string, unknown>): boolean | string => {
218+
const r = celEngine.evaluate(
219+
{ dialect: 'cel', source: visibleOf(SysMember, name) },
220+
{ record: MEMBER_ROW, extra: { current_user: ADMIN, user: ADMIN, ctx: { user: ADMIN }, features } },
221+
);
222+
if (!r.ok) return `FAULT ${r.error.message.split('\n')[0].trim()}`;
223+
return typeof r.value === 'boolean' ? r.value : `NON-BOOLEAN ${JSON.stringify(r.value)}`;
224+
};
225+
226+
it.each(THREE)('sys_member.%s is hidden while the environment is cloud-managed', (name) => {
227+
expect(rowOffered(name, { ...OTHER_FLAGS, cloudManaged: true })).toBe(false);
228+
});
229+
230+
it.each(THREE)('sys_member.%s is offered to the owner as before when the flag is off', (name) => {
231+
expect(rowOffered(name, { ...OTHER_FLAGS, cloudManaged: false })).toBe(true);
232+
});
233+
234+
it.each(THREE)('sys_member.%s keeps its organization gate: off hides it whatever cloudManaged says', (name) => {
235+
expect(rowOffered(name, { organization: false, admin: true, cloudManaged: false })).toBe(false);
236+
});
237+
238+
it('sys_member.add_member stays offered to a platform administrator while the environment is cloud-managed', () => {
239+
expect(rowOffered('add_member', { ...OTHER_FLAGS, cloudManaged: true })).toBe(true);
240+
});
241+
});
242+
243+
/**
244+
* The rest of the membership census: every other action whose door writes or
245+
* deletes a membership row is hidden while the flag is on, each offered as
246+
* before when it is off. Leave Organization ends the caller's membership,
247+
* Create Organization makes the caller an owner, Delete Organization ends
248+
* every membership of the organization, and Accept Invitation creates one.
249+
* Decline Invitation writes no membership, so it is not gated.
250+
*/
251+
describe('features.cloudManaged hides every other action whose door writes or deletes a membership row', () => {
252+
const ORG_ROW = { id: 'org_1', name: 'Org', slug: 'org' };
253+
const INVITATION_ROW = { id: 'inv_1', email: ADMIN.email, status: 'pending', role: 'member', organization_id: 'org_1' };
254+
const MULTI = { ...OTHER_FLAGS, multiOrgEnabled: true };
255+
const FOUR: ReadonlyArray<[string, { actions?: unknown }, string, Record<string, unknown>]> = [
256+
['sys_organization.leave_organization', SysOrganization, 'leave_organization', ORG_ROW],
257+
['sys_organization.create_organization', SysOrganization, 'create_organization', {}],
258+
['sys_organization.delete_organization', SysOrganization, 'delete_organization', ORG_ROW],
259+
['sys_invitation.accept_invitation', SysInvitation, 'accept_invitation', INVITATION_ROW],
260+
];
261+
262+
const offeredOn = (def: { actions?: unknown }, name: string, record: Record<string, unknown>, features: Record<string, unknown>): boolean | string => {
263+
const r = celEngine.evaluate(
264+
{ dialect: 'cel', source: visibleOf(def, name) },
265+
{ record, extra: { current_user: ADMIN, user: ADMIN, ctx: { user: ADMIN }, features } },
266+
);
267+
if (!r.ok) return `FAULT ${r.error.message.split('\n')[0].trim()}`;
268+
return typeof r.value === 'boolean' ? r.value : `NON-BOOLEAN ${JSON.stringify(r.value)}`;
269+
};
270+
271+
it.each(FOUR)('%s is hidden while the environment is cloud-managed', (_site, def, name, record) => {
272+
expect(offeredOn(def, name, record, { ...MULTI, cloudManaged: true })).toBe(false);
273+
});
274+
275+
it.each(FOUR)('%s is offered as before when the flag is off', (_site, def, name, record) => {
276+
expect(offeredOn(def, name, record, { ...MULTI, cloudManaged: false })).toBe(true);
277+
});
278+
279+
// Each keeps its other gate: the three organization actions their
280+
// `multiOrgEnabled` gate, Accept Invitation its pending-row predicate.
281+
const OTHER_GATE_OFF: ReadonlyArray<[string, { actions?: unknown }, string, Record<string, unknown>, Record<string, unknown>]> = [
282+
['sys_organization.leave_organization', SysOrganization, 'leave_organization', ORG_ROW, { ...OTHER_FLAGS, multiOrgEnabled: false, cloudManaged: false }],
283+
['sys_organization.create_organization', SysOrganization, 'create_organization', {}, { ...OTHER_FLAGS, multiOrgEnabled: false, cloudManaged: false }],
284+
['sys_organization.delete_organization', SysOrganization, 'delete_organization', ORG_ROW, { ...OTHER_FLAGS, multiOrgEnabled: false, cloudManaged: false }],
285+
['sys_invitation.accept_invitation', SysInvitation, 'accept_invitation', { ...INVITATION_ROW, status: 'accepted' }, { ...MULTI, cloudManaged: false }],
286+
];
287+
288+
it.each(OTHER_GATE_OFF)('%s keeps its other gate: closed, it hides the action whatever cloudManaged says', (_site, def, name, record, features) => {
289+
expect(offeredOn(def, name, record, features)).toBe(false);
290+
});
291+
292+
it('sys_invitation.reject_invitation, which writes no membership, stays offered while the environment is cloud-managed', () => {
293+
expect(offeredOn(SysInvitation, 'reject_invitation', INVITATION_ROW, { ...MULTI, cloudManaged: true })).toBe(true);
294+
});
295+
});

‎packages/platform-objects/src/identity/sys-invitation.object.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ export const SysInvitation = ObjectSchema.create({
251251
type: 'api',
252252
target: '/api/v1/auth/organization/accept-invitation',
253253
recordIdParam: 'invitationId',
254-
visible: "has(record.email) && record.email == ctx.user.email && has(record.status) && record.status == 'pending'",
254+
// Hidden while cloud-managed: accepting creates a membership, which is
255+
// the hosting organisation's there; the door refuses (409
256+
// RESOURCE_CONFLICT). Decline stays: it writes no membership.
257+
visible: "has(record.email) && record.email == ctx.user.email && has(record.status) && record.status == 'pending' && features.cloudManaged != true",
255258
successMessage: 'Invitation accepted',
256259
refreshAfter: true,
257260
// ADR-0011 identity-actions note, bucket E: exposed by plain declaration.

‎packages/platform-objects/src/identity/sys-member.object.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ export const SysMember = ObjectSchema.create({
228228
type: 'api',
229229
target: '/api/v1/auth/organization/update-member-role',
230230
recordIdParam: 'memberId',
231+
// Hidden while cloud-managed: the hosting organisation manages members
232+
// and their roles there, and the door refuses (409 RESOURCE_CONFLICT).
233+
visible: 'features.cloudManaged != true',
231234
requiresFeature: 'organization',
232235
requiresMembershipReach: 'update_member_role',
233236
successMessage: 'Member role updated',
@@ -254,6 +257,8 @@ export const SysMember = ObjectSchema.create({
254257
type: 'api',
255258
target: '/api/v1/auth/organization/remove-member',
256259
recordIdParam: 'memberIdOrEmail',
260+
// Hidden while cloud-managed, as `update_member_role` above.
261+
visible: 'features.cloudManaged != true',
257262
requiresFeature: 'organization',
258263
requiresMembershipReach: 'remove_member',
259264
confirmText: 'Remove this member from the organization? They will lose access to all org resources.',
@@ -301,7 +306,9 @@ export const SysMember = ObjectSchema.create({
301306
// predicate at key resolution and drop the button silently. `has()`
302307
// alone — the operand is a bare equality against a literal (see
303308
// `materializeDeclaredFields` in `@objectstack/objectql`).
304-
visible: "has(record.role) && record.role != 'owner'",
309+
// Hidden while cloud-managed, as `update_member_role` above (the same
310+
// door).
311+
visible: "has(record.role) && record.role != 'owner' && features.cloudManaged != true",
305312
requiresFeature: 'organization',
306313
requiresMembershipReach: 'transfer_ownership',
307314
confirmText: 'Make the selected member an owner of this organization? They get every owner privilege, including deleting the organization. You stay an owner too; to step down, use Change Role on your own membership.',

‎packages/platform-objects/src/identity/sys-organization.object.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ export const SysOrganization = ObjectSchema.create({
7171
locations: ['list_toolbar'],
7272
type: 'api',
7373
target: '/api/v1/auth/organization/create',
74+
// Hidden while cloud-managed: creating an organization makes the caller
75+
// its owner, and membership is the hosting organisation's there; the
76+
// door refuses (409 RESOURCE_CONFLICT).
77+
visible: 'features.cloudManaged != true',
7478
successMessage: 'Organization created',
7579
refreshAfter: true,
7680
// Hidden when the deployment is provisioned in single-org mode
@@ -132,6 +136,9 @@ export const SysOrganization = ObjectSchema.create({
132136
type: 'api',
133137
target: '/api/v1/auth/organization/delete',
134138
recordIdParam: 'organizationId',
139+
// Hidden while cloud-managed: deleting ends every membership, and the
140+
// door refuses there (409 RESOURCE_CONFLICT).
141+
visible: 'features.cloudManaged != true',
135142
requiresFeature: 'multiOrgEnabled',
136143
// `organization/delete` admits the owner alone (ADR-0108 D1).
137144
requiresMembershipReach: 'delete_organization',
@@ -242,6 +249,9 @@ export const SysOrganization = ObjectSchema.create({
242249
type: 'api',
243250
target: '/api/v1/auth/organization/leave',
244251
recordIdParam: 'organizationId',
252+
// Hidden while cloud-managed: leaving ends a membership, which is the
253+
// hosting organisation's there; the door refuses (409 RESOURCE_CONFLICT).
254+
visible: 'features.cloudManaged != true',
245255
requiresFeature: 'multiOrgEnabled',
246256
// Names what is lost (#24021's copy half, ruling 6228318638 item 2).
247257
confirmText: 'Leave this organization? You will lose access to its environments and members.',

0 commit comments

Comments
 (0)