Many an update!

This commit is contained in:
Jennie Robinson Faber 2025-12-01 15:26:42 +00:00
parent 85195d6c7a
commit d588c49946
35 changed files with 3528 additions and 1142 deletions

View file

@ -4,24 +4,33 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
console.log('🛡️ Auth middleware - skipping on server')
return
}
const { memberData, checkMemberStatus } = useAuth()
const { openLoginModal } = useLoginModal()
console.log('🛡️ Auth middleware (CLIENT) - route:', to.path)
console.log(' - memberData exists:', !!memberData.value)
console.log(' - Running on:', process.server ? 'SERVER' : 'CLIENT')
// If no member data, try to check authentication
if (!memberData.value) {
console.log(' - No member data, checking authentication...')
const isAuthenticated = await checkMemberStatus()
console.log(' - Authentication result:', isAuthenticated)
if (!isAuthenticated) {
console.log(' - ❌ Authentication failed, redirecting to login')
return navigateTo('/login')
console.log(' - ❌ Authentication failed, showing login modal')
// Open login modal instead of redirecting
openLoginModal({
title: 'Sign in to continue',
description: 'You need to be signed in to access this page',
dismissible: true,
redirectTo: to.fullPath,
})
// Abort navigation - stay on current page with modal open
return abortNavigation()
}
}
console.log(' - ✅ Authentication successful for:', memberData.value?.email)
})