Limit functionalities by roles

This commit is contained in:
rotimi-best
2021-09-11 21:52:46 +03:00
parent 220f35b3db
commit 07eba6b4e0
14 changed files with 296 additions and 224 deletions
@@ -0,0 +1,24 @@
<script lang="ts">
// import { ROLE } from '../../utils/constants/roles';
import { profile } from '../../utils/store/user';
import { group } from '../Course/store';
import type { Person } from '../Course/components/People/types';
export let allowedRoles: number[] = [];
let userRole: number = 0;
$: {
const user: Person = $group.people.find(
(person: { profile_id: number }) => person.profile_id === $profile.id
)!;
if (user) {
userRole = user.role_id;
}
}
</script>
{#if allowedRoles.includes(userRole)}
<slot />
{/if}
@@ -0,0 +1 @@
import { writable } from 'svelte/store';