ownership
This commit is contained in:
parent
85289069ba
commit
d98afa259e
5 changed files with 18 additions and 14 deletions
|
@ -5,6 +5,7 @@ export const useAbilityStore = defineStore("ability", {
|
|||
state: () => {
|
||||
return {
|
||||
permissions: {} as PermissionObject,
|
||||
isOwner: false as boolean,
|
||||
};
|
||||
},
|
||||
getters: {
|
||||
|
@ -12,6 +13,7 @@ export const useAbilityStore = defineStore("ability", {
|
|||
(state) =>
|
||||
(type: PermissionType | "admin", section: PermissionSection, module?: PermissionModule): boolean => {
|
||||
const permissions = state.permissions;
|
||||
if (state.isOwner) return true;
|
||||
if (type == "admin") return permissions?.admin ?? false;
|
||||
if (permissions?.admin) return true;
|
||||
if (
|
||||
|
@ -30,6 +32,7 @@ export const useAbilityStore = defineStore("ability", {
|
|||
(state) =>
|
||||
(type: PermissionType | "admin", section: PermissionSection): boolean => {
|
||||
const permissions = state.permissions;
|
||||
if (state.isOwner) return true;
|
||||
if (type == "admin") return permissions?.admin ?? false;
|
||||
if (permissions?.admin) return true;
|
||||
if (
|
||||
|
@ -48,6 +51,7 @@ export const useAbilityStore = defineStore("ability", {
|
|||
section: PermissionSection,
|
||||
module?: PermissionModule
|
||||
): boolean => {
|
||||
// ignores ownership
|
||||
if (type == "admin") return permissions?.admin ?? false;
|
||||
if (permissions?.admin) return true;
|
||||
if (
|
||||
|
@ -64,8 +68,9 @@ export const useAbilityStore = defineStore("ability", {
|
|||
},
|
||||
},
|
||||
actions: {
|
||||
setAbility(permissions: PermissionObject) {
|
||||
setAbility(permissions: PermissionObject, isOwner: boolean) {
|
||||
this.permissions = permissions;
|
||||
this.isOwner = isOwner;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue