Copied staff collections: access guide, API table, changelog, reference index
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
8dcc123b99
commit
c9540d291a
@@ -355,6 +355,43 @@ is kept and can only narrow it. To keep a late collection's rules exactly as the
|
||||
wider `read` — say so on the collection: `custom: { ipal: { accountRules: false } }` (the password rule and the
|
||||
first-user endpoint still apply), or list that plugin before ipalKit.
|
||||
|
||||
**A copy of a staff collection** — a later plugin that spreads one into a new slug (`{ ...staff, slug: 'copy' }`),
|
||||
or a new collection that reuses a staff collection's `access` object — brings along rules the plugin wrote for
|
||||
the ORIGINAL: "an account of `staff`", "the account itself" = one of the original's. The plugin sees them by a
|
||||
mark it puts on its own functions (`staffRuleOf(rule)` → `{ slug, self }`; the mark counts only on the very
|
||||
function it was made for, so a wrapper of yours around a plugin rule is your rule). What it does is one thing,
|
||||
in every case:
|
||||
|
||||
> **The plugin's rule for THIS collection goes in front of the rule that is there, and both must allow.**
|
||||
> Nothing is replaced and nothing is rewritten.
|
||||
|
||||
| The copy | Where the plugin's rule goes in front |
|
||||
|---|---|
|
||||
| named in `access.staffCollections` | of every rule — as on any late staff collection |
|
||||
| not named as staff, or with `custom: { ipal: { accountRules: false } }` | only of the rules the plugin wrote for the original; your own rules there stay as they are |
|
||||
| its `roles` field | guarded on every copy (the plugin's roles: only an admin changes them; others: never one's own) unless the field has an `access.update` of its own — then the guard goes in front only of a rule the plugin wrote for the original |
|
||||
|
||||
So a copy is never opened wider than its rules were before, and never wider than the plugin's rule — whatever
|
||||
role values it has, whichever operation it uses a copied rule for, however it wraps it. The original's account
|
||||
with the same id is not "the account itself" in the copy.
|
||||
|
||||
**The cost, and the one line that pays it:** a copied rule that says "an admin, or the account itself" still
|
||||
means the ORIGINAL's accounts, so in the copy only an admin passes it — the copy's own accounts cannot edit
|
||||
themselves until the copy says who may:
|
||||
|
||||
```ts
|
||||
import { adminOrSelfIn } from '@intecion/ipal-kit'
|
||||
// in the plugin that makes the copy:
|
||||
{ ...staff, slug: 'copy', access: { ...staff.access, update: adminOrSelfIn('copy') } }
|
||||
```
|
||||
|
||||
A rule you write there is not marked, so on a staff copy it is combined with the plugin's rule for `copy`
|
||||
("an admin, or the account itself" of the copy) and works. The password rule is on a copy once
|
||||
(`isPasswordRuleHook`). The marker `custom.ipalAccounts` (`{ slug, staff }`, type `AccountsMarker`) records which
|
||||
collection the plugin has handled and whether as staff: a copy carries the original's marker and is handled under
|
||||
its own slug; in `next dev` a collection named as staff in an edit is handled on the reload. A marker for the
|
||||
collection's own slug means "handled" — only your own config can write one, like `accountRules: false`.
|
||||
|
||||
**A slug in `access.staffCollections` or `access.authCollection` that is not an auth collection of the config:**
|
||||
Payload does not start. The log names the slug and the auth collections it knows. The process stays up, but
|
||||
every Payload call fails — `/api/health` answers 503, `/api/*` and the panel 500; a page that needs no Payload
|
||||
|
||||
Reference in New Issue
Block a user