ability section update
This commit is contained in:
parent
68efdc131b
commit
eff79a4697
3 changed files with 18 additions and 4 deletions
|
@ -26,6 +26,20 @@ export const useAbilityStore = defineStore("ability", {
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
canSection:
|
||||||
|
(state) =>
|
||||||
|
(type: PermissionType | "admin", section: PermissionSection): boolean => {
|
||||||
|
const permissions = state.permissions;
|
||||||
|
if (type == "admin") return permissions.admin ?? false;
|
||||||
|
if (permissions.admin) return true;
|
||||||
|
if (
|
||||||
|
permissions[section]?.all == "*" ||
|
||||||
|
permissions[section]?.all?.includes(type) ||
|
||||||
|
permissions[section] != undefined
|
||||||
|
)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
},
|
||||||
_can:
|
_can:
|
||||||
() =>
|
() =>
|
||||||
(
|
(
|
||||||
|
|
|
@ -81,7 +81,7 @@ export const useNavigationStore = defineStore("navigation", {
|
||||||
updateTopLevel() {
|
updateTopLevel() {
|
||||||
const abilityStore = useAbilityStore();
|
const abilityStore = useAbilityStore();
|
||||||
this.topLevel = [
|
this.topLevel = [
|
||||||
...(abilityStore.can("read", "club")
|
...(abilityStore.canSection("read", "club")
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
key: "club",
|
key: "club",
|
||||||
|
@ -90,7 +90,7 @@ export const useNavigationStore = defineStore("navigation", {
|
||||||
} as topLevelNavigationModel,
|
} as topLevelNavigationModel,
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
...(abilityStore.can("read", "settings")
|
...(abilityStore.canSection("read", "settings")
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
key: "settings",
|
key: "settings",
|
||||||
|
@ -99,7 +99,7 @@ export const useNavigationStore = defineStore("navigation", {
|
||||||
} as topLevelNavigationModel,
|
} as topLevelNavigationModel,
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
...(abilityStore.can("read", "user")
|
...(abilityStore.canSection("read", "user")
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
key: "user",
|
key: "user",
|
||||||
|
|
|
@ -12,7 +12,7 @@ export type PermissionModule =
|
||||||
| "user"
|
| "user"
|
||||||
| "role";
|
| "role";
|
||||||
|
|
||||||
export type PermissionType = "create" | "read" | "update" | "delete";
|
export type PermissionType = "read" | "create" | "update" | "delete";
|
||||||
|
|
||||||
export type PermissionString =
|
export type PermissionString =
|
||||||
| `${PermissionSection}.${PermissionModule}.${PermissionType}` // für spezifische Berechtigungen
|
| `${PermissionSection}.${PermissionModule}.${PermissionType}` // für spezifische Berechtigungen
|
||||||
|
|
Loading…
Reference in a new issue