Repository navigation
Conversation
Business accounts and brands need people to share records under rules the host passes in. This adds the two collections, the last-Owner guard, the fail-closed host hooks, the refuseMember veto, audit hooks and the canView, canEdit and sharedWhere helpers. Tested against real Payload with in-memory MongoDB (45 tests, including two requests at once). Not tested: a database without transactions, a live site, the admin screens in a browser. Co-Authored-By: Michael Gilardi <11632652+mgilardi@users.noreply.github.com> Co-Authored-By: Garfunkel Botsworth <357926774+garfunkelbot@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EXTANT APE's review of the positions PR found problems that could apply here. This checks each against sharing and fixes them: refuseMember is required (false opts out), every delete throws even with overrideAccess, hooks get plain ids plus the id and data of the change, member changes go to an append-only share-member-events history, and Viewers see only Owners and Managers by default. Adds tests for REST, GraphQL, bulk update, server-code revive and widen attempts, and same-id users and organizations. Tested: 61 tests against real Payload with in-memory MongoDB. Not tested: a database without transactions, a live site, the admin screens. Co-Authored-By: Michael Gilardi <11632652+mgilardi@users.noreply.github.com> Co-Authored-By: Garfunkel Botsworth <357926774+garfunkelbot@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… transactions Notes, invitedBy and removedBy are now readable by Owners and Managers only, and notes are capped. A user accepts only their own invitation and canAccept applies to organization members only. A throwing identities hook refuses before any host hook runs. The veto runs for each person behind an organization (peopleOf, required with organizations) and is shown who is acting. The plugin refuses to start without transactions, and bulk member updates are refused so a change and its history row stay together. Tested: 72 tests against real Payload with in-memory MongoDB. Not tested: a live site, the admin screens, a real database without transactions (checked with stand-ins only). Co-Authored-By: Michael Gilardi <11632652+mgilardi@users.noreply.github.com> Co-Authored-By: Garfunkel Botsworth <357926774+garfunkelbot@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…review's gaps canRead is now ORed with the default rules and can only add rows, so true, an empty where or a throw no longer opens every membership. The transactions check opens and rolls back a real transaction, so an adapter set up with transactionOptions: false is refused (allowWithoutTransactions opts out). Self-accept and self-leave can't overwrite staff notes. A removal can't carry a level change, and accept with a level change records both events. The veto runs before the already-a-member check, and invitedBy ignores users from other auth collections. @payloadcms/graphql is pinned. Documented: peopleOf must cover everyone identities maps, the veto is not given current members, and a group's founding owner stays visible. Ids and names are out of the docs. Tested: 83 tests against real Payload with in-memory MongoDB, including a real adapter with transactionOptions: false. Not tested: a live site, the admin screens, a standalone database beyond that adapter case. Co-Authored-By: Michael Gilardi <11632652+mgilardi@users.noreply.github.com> Co-Authored-By: Garfunkel Botsworth <357926774+garfunkelbot@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three describe blocks (members keyed by collection, the history, what a Viewer sees of other members) were lost in the last rewrite of a test; they are back, six tests. identities now keeps an organization only when peopleOf lists the user, asked once per request and dropped on a throw. invitedBy is always the acting user or none. Member changes refuse without a request transaction, so disableTransaction can't skip the lock or the history row. Non-staff can't write notes on an organization's row they act for. The server-code level-change test now exercises the veto itself. Tested: 95 tests against real Payload with in-memory MongoDB. Not tested: a live site, the admin screens. Co-Authored-By: Michael Gilardi <11632652+mgilardi@users.noreply.github.com> Co-Authored-By: Garfunkel Botsworth <357926774+garfunkelbot@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tested: no code changed. Co-Authored-By: Michael Gilardi <11632652+mgilardi@users.noreply.github.com> Co-Authored-By: Garfunkel Botsworth <357926774+garfunkelbot@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First version of the plugin, for Captive Origins task K5228 (account model T5). It follows Captive Origins decisions D5228 (shared collections with Owner, Manager and Viewer, at least one Owner), D5234 (business accounts and brands) and D5239 (a minor may be in a shared collection only through a family group with a linked guardian). The plugin stays agnostic; the minors rule is the host's
refuseMemberveto.What's in it
share-groups(name, host-defined kind, first owner) andshare-members(group, member from users or other collections such as organizations, level, status, audit trail).canCreateGroup,canInvite,canChangeLevel,canRemove,canAccept): only an exacttrueallows.refuseMemberveto on invite, accept and level change; audit hooks; no deletes; aliveKeyunique index stops a second live row.shareGroupField,canView,canEditandsharedWherefor host collections. They return false on any error.Tested: 45 Vitest tests against real Payload 3.92 with in-memory MongoDB, including repeated concurrency rounds; the leak check passes.
Not tested: a database without transactions, a live site, admin screens in a browser.
Open questions for review
canRead; should the default be tighter for kids' groups?canAccepthook. Is that the right default?refuseMembermust check it.🤖 Generated with Claude Code