Tuấn Anh
02/26/2026, 7:51 AMAsk Inkeep
02/26/2026, 7:52 AMAsk Inkeep
02/26/2026, 7:52 AMresourcesAndActions and calls permit.check() for each, returning a permittedList in one response.
const checkPermissions = async (resourceAndAction) => {
const { resource, action, userAttributes, resourceAttributes } = resourceAndAction;
return permit.check(
{ key: userId, attributes: userAttributes },
action,
{ type: resource, attributes: resourceAttributes, tenant: 'default' }
) ;
};
const permittedList = await Promise.all(
resourcesAndActions.map(checkPermissions)
) ;
The permissions are then loaded once on login and stored in a *Pinia store* (Vue) or similar state management, so you don't need to make repeated API calls for each item render. The setAbility function fetches allowed actions/resources from the backend and stores them in CASL for quick UI toggling.
This means your 50 permission checks happen in one bulk request, not 50 separate calls.Ask Inkeep
02/26/2026, 7:52 AMdavid
02/26/2026, 9:35 AM