Replace composable with Pinia store for persistent auth state

This commit is contained in:
Torsten Schulz (local)
2025-10-21 14:19:30 +02:00
parent 1015d37eb7
commit 43071b45a9
10 changed files with 137 additions and 69 deletions

View File

@@ -101,7 +101,7 @@ import { useRouter } from 'vue-router'
import { AlertCircle, Check, Loader2, Lock } from 'lucide-vue-next'
const router = useRouter()
const { checkAuth } = useAuth()
const authStore = useAuthStore()
const formData = ref({
email: '',
@@ -118,20 +118,11 @@ const handleLogin = async () => {
successMessage.value = ''
try {
const response = await $fetch('/api/auth/login', {
method: 'POST',
body: {
email: formData.value.email,
password: formData.value.password
}
})
const response = await authStore.login(formData.value.email, formData.value.password)
if (response.success) {
successMessage.value = 'Anmeldung erfolgreich! Sie werden weitergeleitet...'
// Update global auth state
await checkAuth()
// Redirect based on role
setTimeout(() => {
if (response.user.role === 'admin' || response.user.role === 'vorstand') {