From a005acc1d8e6c2a982b0132d7604a10b40f1396d Mon Sep 17 00:00:00 2001 From: Bradley Shellnut Date: Fri, 13 May 2022 10:22:50 -0700 Subject: [PATCH] Use session to change Nav and implement logout. --- src/routes/__layout.svelte | 17 +++++++++++++---- src/routes/auth/logout/index.ts | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 src/routes/auth/logout/index.ts diff --git a/src/routes/__layout.svelte b/src/routes/__layout.svelte index 5610358..e4a550d 100644 --- a/src/routes/__layout.svelte +++ b/src/routes/__layout.svelte @@ -1,14 +1,23 @@ + + SvelteKit Auth \ No newline at end of file diff --git a/src/routes/auth/logout/index.ts b/src/routes/auth/logout/index.ts new file mode 100644 index 0000000..e097800 --- /dev/null +++ b/src/routes/auth/logout/index.ts @@ -0,0 +1,15 @@ +import type { RequestHandler } from '@sveltejs/kit' +import * as cookie from 'cookie' + +export const get: RequestHandler = async () => { + return { + status: 303, + headers: { + 'Set-Cookie': cookie.serialize('session', '', { + path: '/', + expires: new Date(0), + }), + location: '/', + }, + } +} \ No newline at end of file