2025-03-07 18:43:24 +01:00
|
|
|
<template>
|
|
|
|
<main>
|
|
|
|
<h1>Account Settings</h1>
|
|
|
|
<p>Name: {{ session?.account.name }}</p>
|
|
|
|
<p>Access: {{ session?.account.type }}</p>
|
|
|
|
<p>
|
|
|
|
<PushNotification />
|
|
|
|
</p>
|
2025-03-07 22:28:55 +01:00
|
|
|
<fieldset>
|
|
|
|
<legend>Danger Zone</legend>
|
|
|
|
Delete my account and all data associated with it
|
|
|
|
<button @click="deleteAccount">
|
|
|
|
Delete
|
|
|
|
</button>
|
|
|
|
</fieldset>
|
2025-03-07 18:43:24 +01:00
|
|
|
</main>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
definePageMeta({
|
|
|
|
middleware: ["authenticated"],
|
|
|
|
});
|
|
|
|
|
|
|
|
const { data: session } = useAccountSession();
|
2025-03-07 22:28:55 +01:00
|
|
|
const { refresh: sessionRefresh } = useAccountSession();
|
|
|
|
|
|
|
|
async function deleteAccount() {
|
|
|
|
try {
|
|
|
|
await $fetch.raw("/api/account", {
|
|
|
|
method: "DELETE",
|
|
|
|
});
|
|
|
|
await sessionRefresh();
|
|
|
|
await navigateTo("/");
|
2025-03-07 18:43:24 +01:00
|
|
|
|
2025-03-07 22:28:55 +01:00
|
|
|
} catch (err: any) {
|
|
|
|
alert(`Delete account failed: ${err.statusCode} ${err.statusMessage}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2025-03-07 18:43:24 +01:00
|
|
|
|
2025-03-07 22:28:55 +01:00
|
|
|
<style scoped>
|
|
|
|
fieldset {
|
|
|
|
width: fit-content;
|
|
|
|
}
|
2025-03-07 18:43:24 +01:00
|
|
|
</style>
|