From 4899688740c25e40ee35dc6a32bf37f3eaa87641 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Tue, 20 Aug 2024 10:41:48 +0700 Subject: [PATCH] feat: function in role include --- src/stores/utils/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/stores/utils/index.ts b/src/stores/utils/index.ts index 5eed9e96..3b39f872 100644 --- a/src/stores/utils/index.ts +++ b/src/stores/utils/index.ts @@ -3,6 +3,7 @@ import GlobalDialog from 'components/GlobalDialog.vue'; import { ComposerTranslation, useI18n } from 'vue-i18n'; import { defineStore } from 'pinia'; import { Ref, ref } from 'vue'; +import { getRole } from 'src/services/keycloak'; export const baseUrl = import.meta.env.VITE_API_BASE_URL; @@ -218,4 +219,11 @@ const useUtilsStore = defineStore('utilsStore', () => { }; }); +export function isRoleInclude(role2check: string[]): boolean { + const roles = getRole() ?? []; + const isIncluded = role2check.some((r) => roles.includes(r)); + + return isIncluded; +} + export default useUtilsStore;