@nangazaki/vue-rbac
Version:
Role-Based Access Control (RBAC) implementation for Vue.js
31 lines (30 loc) • 862 B
TypeScript
import type { RBAC } from "@/types";
import type { DirectiveBinding } from "vue";
/**
* Checks if the current user has access based on the provided directive binding and RBAC configuration.
*
* @param binding - Vue directive binding object containing modifiers and values
* @param rbac - RBAC instance for permission/role checking
* @returns boolean indicating if access is granted
*
* @example
* // Role check
* v-rbac:role="'admin'"
*
* @example
* // Any permission check
* v-rbac:any="['users:create', 'users:edit']"
*
* @example
* // All permissions check
* v-rbac:all="['users:create', 'users:edit']"
*
* @example
* // Negated permission check
* v-rbac:not="'users:delete'"
*
* @example
* // Default permission check
* v-rbac="'users:create'"
*/
export declare function checkAccess(binding: DirectiveBinding, rbac: RBAC): boolean;