feat: Delete account functionality
This commit is contained in:
parent
c0688e87b0
commit
51d255d15d
@ -3,6 +3,11 @@ import { username } from 'better-auth/plugins';
|
||||
import Database from 'better-sqlite3';
|
||||
|
||||
export const auth = betterAuth({
|
||||
user: {
|
||||
deleteUser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
database: new Database('./src/lib/server/db/users.db'),
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
|
@ -37,9 +37,16 @@ export const actions = {
|
||||
return fail(400, { newuserForm });
|
||||
}
|
||||
|
||||
return message(newuserForm, 'Password updated.');
|
||||
return message(newuserForm, 'Username updated.');
|
||||
},
|
||||
updateProfilePhoto: async () => {},
|
||||
deleteAccount: async () => {},
|
||||
deleteAccount: async ({ request }) => {
|
||||
auth.api.deleteUser({
|
||||
headers: request.headers,
|
||||
body: {},
|
||||
});
|
||||
|
||||
redirect(303, '/goodbye');
|
||||
},
|
||||
signOut: async () => {},
|
||||
} satisfies Actions;
|
||||
|
@ -1,5 +1,4 @@
|
||||
<script lang="ts">
|
||||
import { Input } from '$lib/components/ui/input/index';
|
||||
import { Button } from '$lib/components/ui/button/index';
|
||||
import * as Dialog from '$lib/components/ui/dialog';
|
||||
|
||||
@ -37,7 +36,7 @@
|
||||
<Dialog.Title>Are you sure absolutely sure?</Dialog.Title>
|
||||
<Dialog.Description>
|
||||
This action cannot be undone. This will permanently delete your account and remove your data from our database.
|
||||
<form class="mt-2 flex gap-2">
|
||||
<form class="mt-2 flex gap-2" method="POST" action="?/deleteAccount">
|
||||
<Button class="w-1/2" onclick={() => (open = !open)}>I changed my mind!</Button>
|
||||
<Button variant="destructive" class="w-1/2" type="submit">Delete Account</Button>
|
||||
</form>
|
||||
|
8
src/routes/goodbye/+page.svelte
Normal file
8
src/routes/goodbye/+page.svelte
Normal file
@ -0,0 +1,8 @@
|
||||
<main class="abs-center flex w-1/4 flex-col items-center gap-4">
|
||||
<h1 class="text-7xl font-bold">Goodbye!</h1>
|
||||
<h3 class="text-center">
|
||||
We're sorry to see you go, if you enjoyed your time on SVChat, come <a class="font-bold underline" href="https://github.com/arithefirst/sv-chat"
|
||||
>star us on GitHub</a
|
||||
>
|
||||
</h3>
|
||||
</main>
|
Loading…
Reference in New Issue
Block a user