@nangazaki/vue-rbac
Version:
Role-Based Access Control (RBAC) implementation for Vue.js
19 lines (18 loc) • 1 kB
TypeScript
import { type IUseRBAC } from "../types/rbac.types";
/**
* Provides access to the RBAC (Role-Based Access Control) context and utility methods.
*
* This composable injects the RBAC context and exposes state and helper functions
* for managing user roles and checking permissions within a Vue application.
*
* @throws {Error} If the RBAC context is not found, indicating the plugin is not installed.
* @returns {IUseRBAC} An object containing the RBAC state and utility methods:
* - `state`: The current RBAC state.
* - `setUserRoles`: Function to set user roles.
* - `hasAllPermissions`: Function to check if user has all specified permissions.
* - `hasAnyPermission`: Function to check if user has any of the specified permissions.
* - `hasPermission`: Function to check if user has a specific permission.
* - `hasRole`: Function to check if user has a specific role.
* - `invalidateCache`: Function to invalidate the cache.
*/
export declare function useRBAC(): IUseRBAC;