Add global auth state with composable for reactive login status

This commit is contained in:
Torsten Schulz (local)
2025-10-21 14:12:01 +02:00
parent 86f21537a8
commit 1015d37eb7
175 changed files with 1618 additions and 2157 deletions

View File

@@ -400,12 +400,9 @@ const isMobileMenuOpen = ref(false)
const mobileSubmenu = ref(null)
const mannschaften = ref([])
const hasGalleryImages = ref(false)
const isLoggedIn = ref(false)
const userRole = ref(null)
const isAdmin = computed(() => {
return userRole.value === 'admin' || userRole.value === 'vorstand'
})
// Use global auth state
const { isLoggedIn, userRole, isAdmin, checkAuth } = useAuth()
// Automatisches Setzen des Submenus basierend auf der Route
const currentSubmenu = computed(() => {
@@ -486,21 +483,10 @@ const checkGalleryImages = async () => {
}
}
const checkAuthStatus = async () => {
try {
const response = await $fetch('/api/auth/status')
isLoggedIn.value = response.isLoggedIn
userRole.value = response.role
} catch (error) {
isLoggedIn.value = false
userRole.value = null
}
}
onMounted(() => {
loadMannschaften()
checkGalleryImages()
checkAuthStatus()
checkAuth()
})
const toggleSubmenu = (menu) => {