Skip to content

Commit

Permalink
update setted permissions value on set
Browse files Browse the repository at this point in the history
  • Loading branch information
gballigand committed May 24, 2024
1 parent d284053 commit 5c88c3a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Bones.UI/composables/usePermissions.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
import { ref } from 'vue'

const _permissions = ref<string[]>([]);
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);
}

const set = (permissions: string[]) => {
_permissions.value = permissions;
_setted.value = true;
}

return {
Expand Down

0 comments on commit 5c88c3a

Please sign in to comment.