feat: Sign out functionality
This commit is contained in:
parent
51d255d15d
commit
b0fc2f7c18
@ -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;
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user