Accessibility fixes.
Some checks are pending
Test / vitest (push) Waiting to run
Test / playwright (push) Blocked by required conditions
Test / visual (push) Blocked by required conditions

This commit is contained in:
Jennie Robinson Faber 2026-04-05 16:03:10 +01:00
parent 4aacb26c4b
commit 88c94aaaf4
12 changed files with 276 additions and 260 deletions

View file

@ -1,36 +1,38 @@
export default defineNuxtRouteMiddleware(async (to, from) => {
// Skip on server-side rendering
if (process.server) {
console.log('🛡️ Auth middleware - skipping on server')
return
console.log("🛡️ Auth middleware - skipping on server");
return;
}
const { memberData, checkMemberStatus } = useAuth()
const { openLoginModal } = useLoginModal()
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')
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)
console.log(" - No member data, checking authentication...");
const isAuthenticated = await checkMemberStatus();
console.log(" - Authentication result:", isAuthenticated);
if (!isAuthenticated) {
console.log(' - ❌ Authentication failed, showing login modal')
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',
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()
});
// Let navigation proceed — the page renders its own unauthenticated
// fallback, and the modal opens on top. abortNavigation() on an initial
// page load resets client state, which closes the modal before it shows.
return;
}
}
console.log(' - ✅ Authentication successful for:', memberData.value?.email)
})
console.log(" - ✅ Authentication successful for:", memberData.value?.email);
});