chore: proper certificate clean up + darkmode nav cleanup
This commit is contained in:
@@ -3,13 +3,14 @@
|
|||||||
import { group } from '../Course/store';
|
import { group } from '../Course/store';
|
||||||
import type { GroupPerson } from '$lib/utils/types';
|
import type { GroupPerson } from '$lib/utils/types';
|
||||||
import { isOrgAdmin } from '$lib/utils/store/org';
|
import { isOrgAdmin } from '$lib/utils/store/org';
|
||||||
import { ROLE } from '$lib/utils/constants/roles';
|
|
||||||
|
|
||||||
export let allowedRoles: number[] = [1, 2, 3];
|
export let allowedRoles: number[] = [];
|
||||||
export let onDenied = () => {};
|
export let onDenied = () => {};
|
||||||
|
// Since orgAdmin can see all, we need a way to show the content only to students
|
||||||
export let onlyStudent = false;
|
export let onlyStudent = false;
|
||||||
|
|
||||||
let userRole: number = 0;
|
let userRole: number = 0;
|
||||||
|
let show = false;
|
||||||
|
|
||||||
function isAllowed(userRole) {
|
function isAllowed(userRole) {
|
||||||
return allowedRoles.includes(userRole);
|
return allowedRoles.includes(userRole);
|
||||||
@@ -25,7 +26,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: show = onlyStudent ? isAllowed(ROLE.STUDENT) : isAllowed(userRole) || $isOrgAdmin;
|
$: if (onlyStudent) {
|
||||||
|
show = isAllowed(userRole);
|
||||||
|
} else {
|
||||||
|
show = isAllowed(userRole) || $isOrgAdmin;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if show}
|
{#if show}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
<RoleBasedSecurity allowedRoles={[1, 2]}>
|
<RoleBasedSecurity allowedRoles={[1, 2]}>
|
||||||
<Design />
|
<Design />
|
||||||
</RoleBasedSecurity>
|
</RoleBasedSecurity>
|
||||||
<RoleBasedSecurity onlyStudent>
|
<RoleBasedSecurity onlyStudent allowedRoles={[3]}>
|
||||||
<StudentCertificate />
|
<StudentCertificate />
|
||||||
</RoleBasedSecurity>
|
</RoleBasedSecurity>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user