From 5c88c3abe80119228148b30e6d56cad57e4b0ffb Mon Sep 17 00:00:00 2001 From: gballigand Date: Fri, 24 May 2024 08:52:20 +0200 Subject: [PATCH] update setted permissions value on set --- src/Bones.UI/composables/usePermissions.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Bones.UI/composables/usePermissions.ts b/src/Bones.UI/composables/usePermissions.ts index fe2e064..f58db58 100644 --- a/src/Bones.UI/composables/usePermissions.ts +++ b/src/Bones.UI/composables/usePermissions.ts @@ -1,26 +1,26 @@ import { ref } from 'vue' const _permissions = ref([]); -const _setted = false; +const _setted = ref(false); export function usePermissions() { const some = (...permissionCodes: string[]) => { - if (!_setted) { + if (!_setted.value) { console.warn("Permissions not setted yet"); } return _permissions.value.some(p => permissionCodes.includes(p)); } const every = (...permissionCodes: string[]) => { - if (!_setted) { + if (!_setted.value) { console.warn("Permissions not setted yet"); } return permissionCodes.every(p => _permissions.value.includes(p)); } const has = (permissionCode: string) => { - if (!_setted) { + if (!_setted.value) { console.warn("Permissions not setted yet"); } return _permissions.value.includes(permissionCode); @@ -28,6 +28,7 @@ export function usePermissions() { const set = (permissions: string[]) => { _permissions.value = permissions; + _setted.value = true; } return {