- Login-Seite, Auth-Store und Router-Guard mit Weiterleitung nach dem Login - API-Client sendet X-CSRF-Token und reagiert auf 401 - Konto: Passwort ändern, angemeldete Geräte anzeigen und widerrufen - Benutzerverwaltung für Admins: anlegen, Rolle, aktiv, Passwort-Reset, löschen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
731 B
TypeScript
32 lines
731 B
TypeScript
import { defineStore } from 'pinia'
|
|
import { ref } from 'vue'
|
|
|
|
import { api } from '@/api/client'
|
|
|
|
export interface Health {
|
|
status: 'ok' | 'error'
|
|
version: string
|
|
db: 'ok' | 'error'
|
|
}
|
|
|
|
export const useHealthStore = defineStore('health', () => {
|
|
const health = ref<Health | null>(null)
|
|
const error = ref<string | null>(null)
|
|
const loading = ref(false)
|
|
|
|
async function refresh(): Promise<void> {
|
|
loading.value = true
|
|
error.value = null
|
|
try {
|
|
health.value = await api.get<Health>('/health')
|
|
} catch (e) {
|
|
health.value = null
|
|
error.value = e instanceof Error ? e.message : String(e)
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
return { health, error, loading, refresh }
|
|
})
|