Use a pinia store to manage session state
Replace the convoluted useAccountSession composable with a pinia store that in addition allows for the consolidation of all session related functions to grouped into one module.
This commit is contained in:
parent
c47452a8b4
commit
fae8b4e2e4
21 changed files with 181 additions and 118 deletions
|
@ -1,19 +1,7 @@
|
|||
<template>
|
||||
<button type="button" @click="logOut">Log out</button>
|
||||
<button type="button" @click="sessionStore.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}`);
|
||||
}
|
||||
}
|
||||
const sessionStore = useSessionStore();
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue