Pull Log Out button into its own component
This commit is contained in:
parent
db9a12250e
commit
3535105744
3 changed files with 26 additions and 18 deletions
19
components/LogOutButton.vue
Normal file
19
components/LogOutButton.vue
Normal 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>
|
Loading…
Add table
Add a link
Reference in a new issue