Pull Log Out button into its own component

This commit is contained in:
Hornwitser 2025-03-07 21:46:44 +01:00
parent db9a12250e
commit 3535105744
3 changed files with 26 additions and 18 deletions

View file

@ -0,0 +1,19 @@
<template>
<button type="button" @click="logOut">Log out</button>
</template>
<script setup lang="ts">
const { refresh: sessionRefresh } = useAccountSession();
async function logOut() {
try {
await $fetch.raw("/api/auth/session", {
method: "DELETE",
});
await sessionRefresh();
} catch (err: any) {
alert(`Log out failed: ${err.statusCode} ${err.statusMessage}`);
}
}
</script>