import { defineStore } from 'pinia' import { ref, computed } from 'vue' import type { User } from '@/types' export const useAuthStore = defineStore('auth', () => { // Bootstrapped from the SPA shell injected by SpaController const user = ref( (window as unknown as Record).__PF_USER__ as User | null ?? null ) const isAuthenticated = computed(() => user.value !== null) function setUser(u: User | null) { user.value = u } return { user, isAuthenticated, setUser } })