init commit
This commit is contained in:
commit
dfe324cf8f
43 changed files with 4237 additions and 0 deletions
54
src/routes/delete-account/+page.svelte
Normal file
54
src/routes/delete-account/+page.svelte
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<script lang="ts">
|
||||
import { goto } from "$app/navigation";
|
||||
import { PUBLIC_BACKEND_API_HOST } from "$env/static/public";
|
||||
import ErrorPopup from "$lib/ErrorPopup.svelte";
|
||||
|
||||
let errorMessage: string | null = $state(null);
|
||||
|
||||
async function handleSubmit(e: SubmitEvent) {
|
||||
e.preventDefault();
|
||||
errorMessage = null;
|
||||
|
||||
try {
|
||||
const res = await fetch(`${PUBLIC_BACKEND_API_HOST}/api/v1/user/me`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
|
||||
let data = await res.json();
|
||||
|
||||
if (!res.ok) {
|
||||
errorMessage = data?.msg || "Something went wrong";
|
||||
return;
|
||||
}
|
||||
|
||||
alert(data.msg || 'Account successfully deleted');
|
||||
goto("/register");
|
||||
} catch (err: any) {
|
||||
errorMessage = err?.msg || "Network error";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col items-center justify-center min-h-full">
|
||||
<form
|
||||
class="formset bg-base-200 border-base-300 rounded-box w-xs border p-4 z-1 translate-y-2"
|
||||
onsubmit={handleSubmit}>
|
||||
<legend class="fieldset-legend">Are you sure you want to delete your account?</legend>
|
||||
<button class="btn btn-error w-full mt-2 mb-3" type="submit">Delete my account</button>
|
||||
<div role="alert" class="alert p-0 mb-2 flex flex-column justify-center">
|
||||
<svg class="stroke-error h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
||||
<span class="mr-auto text-xs text-error">This action is irreversible</span>
|
||||
</div>
|
||||
<div role="alert" class="alert p-0 my-2 flex flex-column justify-center">
|
||||
<svg class="stroke-error h-4 w-4 flex-shrink-0" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
||||
<span class="mr-auto text-xs text-error">All your DNS records will be deleted</span>
|
||||
</div>
|
||||
<div role="alert" class="alert p-0 my-2 flex flex-column justify-center">
|
||||
<svg class="stroke-error h-4 w-4 flex-shrink-0" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
||||
<span class="mr-auto text-xs text-error">Anyone will be able to register your currently owned subdomains. Make sure you understand the security implications of this</span>
|
||||
</div>
|
||||
</form>
|
||||
<div class="mt-3 h-12 flex items-center">
|
||||
<ErrorPopup {errorMessage} />
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue