Restrict access to Mangers and above.
This commit is contained in:
@@ -1,12 +1,26 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import { ae_loc, ae_sess, ae_api, slct } from '$lib/stores/ae_stores';
|
||||
import { Building, Globe, Users, ShieldCheck, List, LayoutDashboard, MapPin, Phone, History } from 'lucide-svelte';
|
||||
import { Building, Globe, Users, ShieldCheck, List, LayoutDashboard, MapPin, Phone, History, Lock } from 'lucide-svelte';
|
||||
|
||||
interface Props {
|
||||
data: any;
|
||||
children?: import('svelte').Snippet;
|
||||
}
|
||||
let { data, children }: Props = $props();
|
||||
|
||||
onMount(() => {
|
||||
if (!$ae_loc.manager_access) {
|
||||
// Wait for a second to see if the permissions load before redirecting.
|
||||
setTimeout(() => {
|
||||
if (!$ae_loc.manager_access) {
|
||||
console.log('Access Denied to /core. Redirecting to home.');
|
||||
goto('/');
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -44,9 +58,20 @@
|
||||
<List size={14} class="mr-1" /> Lookups
|
||||
</a>
|
||||
</nav>
|
||||
{/if}
|
||||
|
||||
<section class="main_content grow px-1 md:px-2 pb-28">
|
||||
{@render children?.()}
|
||||
</section>
|
||||
<section class="main_content grow px-1 md:px-2 pb-28">
|
||||
{@render children?.()}
|
||||
</section>
|
||||
{:else}
|
||||
<section class="flex flex-col items-center justify-center grow text-center space-y-4 py-20">
|
||||
<div class="p-6 bg-error-500/10 rounded-full">
|
||||
<Lock size={64} class="text-error-500" />
|
||||
</div>
|
||||
<h1 class="h1 font-black">Access Restricted</h1>
|
||||
<p class="max-w-md opacity-70">The area you are trying to access is reserved for system managers. If you believe you should have access, please sign in with an authorized account.</p>
|
||||
<div class="flex gap-4 pt-4">
|
||||
<a href="/" class="btn variant-filled-primary font-bold">Return Home</a>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
</div>
|
||||
Reference in New Issue
Block a user