slightly improve logout

This commit is contained in:
Alexander Bocken 2023-07-23 15:39:20 +02:00
parent 0d5d936ef3
commit ea8496b85a
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8
2 changed files with 12 additions and 16 deletions

View File

@ -1,7 +1,8 @@
import { redirect } from "@sveltejs/kit"
import type { Actions, PageServerLoad } from "./$types"
import redirect from "@sveltejs/kit"
import type { Actions } from './$types';
export const load: PageServerLoad = async ({ cookies }) => {
export const actions: Actions = {
default: async ({cookies}) => {
cookies.delete("UserSession")
redirect(303, "/")
}
} satisfies Actions;

View File

@ -1,12 +1,7 @@
<script>
import { redirect } from "@sveltejs/kit";
import { afterNavigate } from '$app/navigation';
import { onMount } from "svelte";
afterNavigate(() => {
redirect(303, "/")
})
onMount(() => {
redirect(303, "/")
})
import "$lib/css/form.css"
</script>
<h1>Log Out</h1>
<form method='POST'>
<h1>Log out</h1>
<button type='submit'>Log Out</button>
</form>