checkPermissionStatus
checkPermissionStatus(
grants,descriptors):ActionPermissionStatus
Defined in: packages/actions/src/create-actions.ts:42
Checks a user’s grants against a set of permission descriptors and returns an ActionPermissionStatus.
If no descriptors are provided the action is unconditionally permitted.
When some descriptors are denied, permitted is false and reason
lists the missing permissions. When all descriptors are denied,
invisible is also true (indicating the UI should hide the control entirely).
Parameters
Section titled “Parameters”grants
Section titled “grants”Grant[]
The user’s resolved permission grants.
descriptors
Section titled “descriptors”Permission descriptors extracted from an operation.
Returns
Section titled “Returns”The resolved ActionPermissionStatus for the action.
Example
Section titled “Example”import { checkPermissionStatus } from "@cfast/actions";
const status = checkPermissionStatus(user.grants, operation.permissions);if (!status.permitted) { console.log(status.reason); // "Missing permissions: delete on posts"}