mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 02:57:57 +00:00 
			
		
		
		
	 77b718c22c
			
		
	
	77b718c22c
	
	
	
		
			
			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>
 |