2025-06-30 18:58:24 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: © 2025 Hornwitser <code@hornwitser.no>
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
-->
|
2025-03-07 18:43:24 +01:00
|
|
|
<template>
|
|
|
|
<main>
|
|
|
|
<h1>Account Settings</h1>
|
2025-05-24 20:01:23 +02:00
|
|
|
<p v-if="accountStore.type !== 'anonymous'">
|
|
|
|
Name: {{ accountStore.name }}
|
2025-03-07 23:53:57 +01:00
|
|
|
</p>
|
2025-05-24 20:01:23 +02:00
|
|
|
<p>Access: {{ accountStore.type }}</p>
|
2025-03-09 15:53:51 +01:00
|
|
|
<form @submit.prevent="changeSettings">
|
|
|
|
<label>
|
|
|
|
Timezone
|
2025-05-24 20:01:23 +02:00
|
|
|
<input type="text" v-model="timezone" :placeholder="accountStore.defaultTimezone">
|
2025-03-09 15:53:51 +01:00
|
|
|
</label>
|
2025-06-13 21:50:22 +02:00
|
|
|
<label>
|
|
|
|
Locale
|
|
|
|
<input type="text" v-model="locale" :placeholder="accountStore.defaultLocale">
|
|
|
|
</label>
|
2025-03-09 15:53:51 +01:00
|
|
|
<button type="submit">
|
|
|
|
Save
|
|
|
|
</button>
|
|
|
|
</form>
|
2025-03-07 18:43:24 +01:00
|
|
|
<p>
|
2025-05-23 21:35:19 +02:00
|
|
|
<ClientOnly>
|
|
|
|
<PushNotification />
|
|
|
|
</ClientOnly>
|
2025-03-07 18:43:24 +01:00
|
|
|
</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"],
|
|
|
|
});
|
|
|
|
|
2025-05-24 17:53:33 +02:00
|
|
|
const sessionStore = useSessionStore();
|
2025-05-24 20:01:23 +02:00
|
|
|
const accountStore = useAccountStore();
|
2025-03-07 22:28:55 +01:00
|
|
|
|
2025-05-24 20:01:23 +02:00
|
|
|
const timezone = ref(accountStore.timezone ?? "");
|
2025-06-13 21:50:22 +02:00
|
|
|
const locale = ref(accountStore.locale ?? "");
|
2025-03-09 15:53:51 +01:00
|
|
|
|
|
|
|
async function changeSettings() {
|
|
|
|
try {
|
2025-05-31 21:44:19 +02:00
|
|
|
await $fetch("/api/auth/account", {
|
2025-03-09 15:53:51 +01:00
|
|
|
method: "patch",
|
|
|
|
body: {
|
|
|
|
timezone: timezone.value,
|
2025-06-13 21:50:22 +02:00
|
|
|
locale: locale.value,
|
2025-03-09 15:53:51 +01:00
|
|
|
}
|
|
|
|
});
|
2025-05-24 17:53:33 +02:00
|
|
|
await sessionStore.fetch();
|
2025-03-09 15:53:51 +01:00
|
|
|
} catch (err: any) {
|
|
|
|
alert(err.data.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-03-07 22:28:55 +01:00
|
|
|
async function deleteAccount() {
|
|
|
|
try {
|
2025-05-31 21:44:19 +02:00
|
|
|
await $fetch.raw("/api/auth/account", {
|
2025-03-07 22:28:55 +01:00
|
|
|
method: "DELETE",
|
|
|
|
});
|
2025-05-24 17:53:33 +02:00
|
|
|
await sessionStore.fetch();
|
2025-03-07 22:28:55 +01:00
|
|
|
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>
|