From b0fc2f7c18ab29363ebab4797fb68ca0b52fa760 Mon Sep 17 00:00:00 2001 From: April Hall Date: Sat, 15 Feb 2025 21:04:13 -0500 Subject: [PATCH] feat: Sign out functionality --- src/routes/(main)/account/+page.server.ts | 10 ++++++++-- src/routes/(main)/account/+page.svelte | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/routes/(main)/account/+page.server.ts b/src/routes/(main)/account/+page.server.ts index 5ab010d..cdcb215 100644 --- a/src/routes/(main)/account/+page.server.ts +++ b/src/routes/(main)/account/+page.server.ts @@ -1,6 +1,6 @@ import { redirect } from '@sveltejs/kit'; import type { Actions } from '@sveltejs/kit'; -import { fail, message, setError, superValidate } from 'sveltekit-superforms'; +import { fail, message, superValidate } from 'sveltekit-superforms'; import { zod } from 'sveltekit-superforms/adapters'; import { auth } from '$lib/server/db/auth'; import { changeUsernameSchema, changePasswordSchema } from '$lib/types/schema.js'; @@ -48,5 +48,11 @@ export const actions = { redirect(303, '/goodbye'); }, - signOut: async () => {}, + signOut: async ({ request }) => { + auth.api.signOut({ + headers: request.headers, + }); + + redirect(303, '/login'); + }, } satisfies Actions; diff --git a/src/routes/(main)/account/+page.svelte b/src/routes/(main)/account/+page.svelte index 5db0d8e..8784b4b 100644 --- a/src/routes/(main)/account/+page.svelte +++ b/src/routes/(main)/account/+page.svelte @@ -21,7 +21,7 @@
Account Actions -
+