Line 0
Link Here
|
0 |
- |
1 |
import { defineStore } from "pinia"; |
|
|
2 |
|
3 |
export const usePermissionsStore = defineStore("permissions", { |
4 |
state: () => ({ |
5 |
userPermissions: null, |
6 |
}), |
7 |
actions: { |
8 |
isUserPermitted(operation, permissions) { |
9 |
const userPermissions = permissions |
10 |
? permissions |
11 |
: this.userPermissions; |
12 |
if (!operation) return true; |
13 |
if (!userPermissions) return false; |
14 |
|
15 |
return ( |
16 |
userPermissions.hasOwnProperty(operation) && |
17 |
userPermissions[operation] |
18 |
); |
19 |
}, |
20 |
}, |
21 |
}); |