Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account deletion #31

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/routes/account/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
<a class="button" href="/changeUsername">Change Username</a>
<a class="button" href="/changeEmail">Change Email</a>
<a class="button" href="/changePassword">Change Password</a>
<a class="button" href="/deleteAccount">Delete Account</a>
</div>
</div>
</div>
Expand Down
43 changes: 43 additions & 0 deletions src/routes/deleteAccount/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<script lang="ts">
import Navbar from "$lib/components/navbar.svelte";
import { browser } from "$app/environment";
import { token } from "$lib/user";
import { goto } from "$app/navigation";
import { api } from "$lib/api";

let password: string;
let error: HTMLSpanElement;

function submit() {
error.textContent = "";

api("account/deleteAccount?password=" + password, true, "POST")
.then(() => goto("/login"))
.catch(reason => error.textContent = reason);
}

$: if (browser && !$token) goto("/login");
</script>

<Navbar/>

<form on:submit|preventDefault={submit}>
<h1>Delete Account</h1>
<p>By deleting your account, all associated data will be permanently erased,
your chat permissions in our Discord server will be revoked,
and you will be logged out and redirected to the login page.<br>
This action is irreversible. Please enter your password to confirm.</p>

<label for="password" class="form-label"><b>Password</b></label>
<!-- svelte-ignore a11y-autofocus -->
<input bind:value={password} type="password" placeholder="Password" id="password" name="password" required autofocus>

<span bind:this={error} class="error"></span>

<button type="submit" class="form-button">Confirm</button>
</form>

<!-- svelte-ignore css-unused-selector -->
<style>
@import "form.css";
</style>