Skip to content

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).

Grant[]

The user’s resolved permission grants.

PermissionDescriptor[]

Permission descriptors extracted from an operation.

ActionPermissionStatus

The resolved ActionPermissionStatus for the action.

import { checkPermissionStatus } from "@cfast/actions";
const status = checkPermissionStatus(user.grants, operation.permissions);
if (!status.permitted) {
console.log(status.reason); // "Missing permissions: delete on posts"
}