- Remove apps/dispatch/ (100% replaced by ops dispatch module, unmaintained) - Commit services/targo-hub/lib/ (24 modules, 6290 lines — was never tracked) - Commit services/docuseal + services/legacy-db docker-compose configs - Extract client app composables: useOTP, useAddressSearch, catalog data, format utils - Refactor CartPage.vue 630→175 lines, CatalogPage.vue 375→95 lines - Clean hardcoded credentials from config.js fallback values - Add client portal: catalog, cart, checkout, OTP verification, address search - Add ops: NetworkPage, AgentFlowsPage, ConversationPanel, UnifiedCreateModal - Add ops composables: useBestTech, useConversations, usePermissions, useScanner - Add field app: scanner composable, docker/nginx configs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
28 lines
786 B
JavaScript
28 lines
786 B
JavaScript
import { defineStore } from 'pinia'
|
|
import { ref } from 'vue'
|
|
import { getLoggedUser, logout } from 'src/api/auth'
|
|
import { usePermissions } from 'src/composables/usePermissions'
|
|
|
|
export const useAuthStore = defineStore('auth', () => {
|
|
const user = ref(null)
|
|
const loading = ref(true)
|
|
const { loadPermissions } = usePermissions()
|
|
|
|
async function checkSession () {
|
|
loading.value = true
|
|
try {
|
|
user.value = await getLoggedUser()
|
|
// Load permissions from targo-hub using the user's email
|
|
if (user.value && user.value !== 'authenticated') {
|
|
await loadPermissions(user.value)
|
|
}
|
|
} catch {
|
|
user.value = 'authenticated'
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
return { user, loading, checkSession, doLogout: logout }
|
|
})
|