feat: Sign out functionality

This commit is contained in:
April Hall 2025-02-15 21:04:13 -05:00
parent 51d255d15d
commit b0fc2f7c18
Signed by: arithefirst
GPG Key ID: 4508A15C4DB91C5B
2 changed files with 9 additions and 3 deletions

View File

@ -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;

View File

@ -21,7 +21,7 @@
<div class="grid w-full items-start gap-3">
<fieldset class="grid w-full gap-3 rounded-lg border p-4">
<legend class="-ml-1 px-1 text-sm font-medium"> Account Actions </legend>
<form>
<form method="POST" action="?/signOut">
<Button type="submit" class="w-full">Sign Out</Button>
</form>
<Button variant="destructive" class="w-full" onclick={() => (open = !open)}>Delete Account</Button>