add admin logout
This commit is contained in:
@@ -2,6 +2,19 @@
|
||||
import { page } from '$app/stores';
|
||||
import { env } from '$env/dynamic/public';
|
||||
import { IconOutline } from 'svelte-heros-v2';
|
||||
import { buttonTriggeredRequest } from '$lib/components/utils';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
async function logout() {
|
||||
const response = await fetch(`${env.PUBLIC_BASE_PATH}/admin/logout`, {
|
||||
method: 'POST'
|
||||
});
|
||||
if (response.ok) {
|
||||
await goto(`${env.PUBLIC_BASE_PATH}/`);
|
||||
} else {
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if $page.url.pathname !== `${env.PUBLIC_BASE_PATH}/admin/login`}
|
||||
@@ -14,6 +27,12 @@
|
||||
<span class="ml-1">Website Admins</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="mt-auto">
|
||||
<button on:click={(e) => buttonTriggeredRequest(e, logout())}>
|
||||
<IconOutline name="arrow-left-on-rectangle-outline" />
|
||||
<span class="ml-1">Ausloggen</span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="h-full w-full">
|
||||
|
||||
Reference in New Issue
Block a user