ResourcePermissionChecker
ResourcePermissionChecker = (
resource,userId,crudAction) =>Promise<boolean|undefined> |boolean|undefined
Type for a function that checks if a user has permission to perform a CRUD action on a resource. Used to implement resource-level access control logic. The function can be synchronous or asynchronous.
Parameters
resource
userId
string
crudAction
Returns
Promise<boolean | undefined> | boolean | undefined
Example
const canEdit: ResourcePermissionChecker = (resource, userId, action) => {
return resource.ownerId === userId && action === crudActions.update;
};