Interface: VueRbac
Defined in: packages/vue/src/state.ts:30
Client-side, reactive view of the current user's roles & permissions.
Every check reads reactive state, so calling it inside computed, a template or a render function re-runs when VueRbac.setSnapshot is called.
This is for UI only: the server must always enforce authorization.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
loading | readonly | Readonly<Ref<boolean>> | true until the first setSnapshot() when created with loading: true (reactive). | packages/vue/src/state.ts:34 |
snapshot | readonly | Readonly<Ref<DeepReadonly<RbacSnapshot>>> | Current snapshot (read-only, reactive). | packages/vue/src/state.ts:32 |
Methods
can()
can(permission): boolean;Defined in: packages/vue/src/state.ts:38
true if the user has the permission (or, for a list, ALL of them).
Parameters
| Parameter | Type |
|---|---|
permission | NameList |
Returns
boolean
canAll()
canAll(permissions): boolean;Defined in: packages/vue/src/state.ts:41
Parameters
| Parameter | Type |
|---|---|
permissions | NameList |
Returns
boolean
canAny()
canAny(permissions): boolean;Defined in: packages/vue/src/state.ts:40
Parameters
| Parameter | Type |
|---|---|
permissions | NameList |
Returns
boolean
cannot()
cannot(permission): boolean;Defined in: packages/vue/src/state.ts:39
Parameters
| Parameter | Type |
|---|---|
permission | NameList |
Returns
boolean
hasAllRoles()
hasAllRoles(roles): boolean;Defined in: packages/vue/src/state.ts:45
Parameters
| Parameter | Type |
|---|---|
roles | NameList |
Returns
boolean
hasAnyRole()
hasAnyRole(roles): boolean;Defined in: packages/vue/src/state.ts:44
Parameters
| Parameter | Type |
|---|---|
roles | NameList |
Returns
boolean
hasRole()
hasRole(roles): boolean;Defined in: packages/vue/src/state.ts:43
true if the user has the role, or ANY of the roles. Supports 'writer|editor'.
Parameters
| Parameter | Type |
|---|---|
roles | NameList |
Returns
boolean
isSuperAdmin()
isSuperAdmin(): boolean;Defined in: packages/vue/src/state.ts:47
true if the user has one of the configured superAdminRoles.
Returns
boolean
setSnapshot()
setSnapshot(snapshot): void;Defined in: packages/vue/src/state.ts:36
Replaces the snapshot, e.g. after login (snapshot) or logout (null). Ends the loading state.
Parameters
| Parameter | Type |
|---|---|
snapshot | RbacSnapshot | null |
Returns
void
