felicity-lims/webapp/guards/pages.ts

20 lines
470 B
TypeScript
Raw Normal View History

import { useAuthStore } from '@/stores';
import { IGroup } from '@/models/auth';
2023-11-10 14:05:15 +08:00
2024-03-26 21:37:21 +08:00
function canAccessPage(pageName: string) {
2023-11-10 14:05:15 +08:00
const authStore = useAuthStore();
const groups = authStore.auth?.user?.groups;
if (!groups || groups?.length == 0) return false;
const group = groups![0] as IGroup;
if (group?.pages) {
return group?.pages?.toLowerCase()?.includes(pageName?.toLowerCase());
2023-11-10 14:05:15 +08:00
}
return false;
}
export default canAccessPage;