Add delete account function
This commit is contained in:
parent
3535105744
commit
598b9fd7d6
5 changed files with 96 additions and 19 deletions
|
@ -6,6 +6,13 @@
|
|||
<p>
|
||||
<PushNotification />
|
||||
</p>
|
||||
<fieldset>
|
||||
<legend>Danger Zone</legend>
|
||||
Delete my account and all data associated with it
|
||||
<button @click="deleteAccount">
|
||||
Delete
|
||||
</button>
|
||||
</fieldset>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
|
@ -15,8 +22,24 @@ definePageMeta({
|
|||
});
|
||||
|
||||
const { data: session } = useAccountSession();
|
||||
const { refresh: sessionRefresh } = useAccountSession();
|
||||
|
||||
async function deleteAccount() {
|
||||
try {
|
||||
await $fetch.raw("/api/account", {
|
||||
method: "DELETE",
|
||||
});
|
||||
await sessionRefresh();
|
||||
await navigateTo("/");
|
||||
|
||||
} catch (err: any) {
|
||||
alert(`Delete account failed: ${err.statusCode} ${err.statusMessage}`);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
<style scoped>
|
||||
fieldset {
|
||||
width: fit-content;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue