feat: function in role include

This commit is contained in:
puriphatt 2024-08-20 10:41:48 +07:00
parent 709c98e08c
commit 4899688740

View file

@ -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;