mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-30 18:47:51 +00:00
Remove the `user.permissions` field and resolve the permissions directly from the accounts array in the user. This change ensures that the cache or previous values from the last active account don't affect the permissions. In this PR: - Remove user.permissions usage, replace it with getUserPermissions method. - Remove json.permissions from user.json.jbuilder
33 lines
792 B
Vue
33 lines
792 B
Vue
<script setup>
|
|
import { useStoreGetters } from 'dashboard/composables/store';
|
|
import { computed } from 'vue';
|
|
import {
|
|
getUserPermissions,
|
|
hasPermissions,
|
|
} from '../helper/permissionsHelper';
|
|
|
|
const props = defineProps({
|
|
permissions: {
|
|
type: Array,
|
|
required: true,
|
|
},
|
|
});
|
|
|
|
const getters = useStoreGetters();
|
|
const user = computed(() => getters.getCurrentUser.value);
|
|
const accountId = computed(() => getters.getCurrentAccountId.value);
|
|
const userPermissions = computed(() => {
|
|
return getUserPermissions(user.value, accountId.value);
|
|
});
|
|
const hasPermission = computed(() => {
|
|
return hasPermissions(props.permissions, userPermissions.value);
|
|
});
|
|
</script>
|
|
|
|
<!-- eslint-disable vue/no-root-v-if -->
|
|
<template>
|
|
<div v-if="hasPermission">
|
|
<slot />
|
|
</div>
|
|
</template>
|