Replace composable with Pinia store for persistent auth state
This commit is contained in:
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user