Skip to main content

checkPermission

@abimongo/core v1.1.4


@abimongo/core / checkPermission

Function: checkPermission()

checkPermission(role, permission): Promise<boolean>

Defined in: core/src/middleware/rbac/rbacMiddleware.ts:45

Check if a user has a specific permission

Parameters

role

Role

The role of the user

permission

Permission

The permission to check

Returns

Promise<boolean>

A promise that resolves to true if the user has the permission, false otherwise

Example

const hasPermission = await checkPermission('admin', 'createUser');
if (hasPermission) {
// User has permission to create a user
} else {
// User does not have permission to create a user
}