diff options
Diffstat (limited to 'web/stores/auth.ts')
| -rw-r--r-- | web/stores/auth.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/web/stores/auth.ts b/web/stores/auth.ts new file mode 100644 index 0000000..71ba5c0 --- /dev/null +++ b/web/stores/auth.ts @@ -0,0 +1,12 @@ +import { useLocalStorage } from "@vueuse/core"; +import { defineStore } from "pinia"; + +export const useAuthStore = defineStore('auth', () => { + const token = useLocalStorage('auth/token', null) + const username = useLocalStorage('auth/username', null) + const admin = useLocalStorage('auth/admin', false) + + const isLoggedIn = () => token.value != null + + return {token, username, admin, isLoggedIn} +}) |
