[dyad] Rol erişim testlerini pinle

This commit is contained in:
[dyad] committed 2026-08-02 11:28:12 +02:00
1 parent fbf6424286
commit f88c294b45
1 file changed
+6 -1
+6 -1
View File
@@ -32,13 +32,18 @@ const vicePrincipalViews: ViewName[] = [
'analytics', 'disciplinary', 'school-transport', 'substitute-teacher', 'analytics', 'disciplinary', 'school-transport', 'substitute-teacher',
]; ];
export function hasRoleAccess(role: string | undefined, allowedRoles: readonly AppRole[]): boolean {
return role === 'SCHOOL_ADMIN' || role === 'SUPER_ADMIN' || (role !== undefined && allowedRoles.includes(role as AppRole));
}
export function canAccessView(role: string | undefined, view: ViewName): boolean { export function canAccessView(role: string | undefined, view: ViewName): boolean {
if (role === 'SCHOOL_ADMIN' || role === 'SUPER_ADMIN') return true; if (role === 'SCHOOL_ADMIN' || role === 'SUPER_ADMIN') return true;
const allowed = role === 'PARENT' ? parentViews const allowed = role === 'PARENT' ? parentViews
: role === 'STUDENT' ? studentViews : role === 'STUDENT' ? studentViews
: role === 'TEACHER' ? teacherViews
: role === 'VICE_PRINCIPAL' ? vicePrincipalViews : role === 'VICE_PRINCIPAL' ? vicePrincipalViews
: role === 'DPO' ? ['dashboard', 'settings', 'reports'] : role === 'DPO' ? ['dashboard', 'settings', 'reports']
: teacherViews; : [];
return allowed.includes(view); return allowed.includes(view);
} }