chore: standardize dev-only debug logging across all three SPAs

Router guards:
- apps/app: added DEV-gated logging matching admin pattern
  (route info, auth decisions, org selection, access granted/denied)
- apps/portal: added DEV-gated logging matching admin pattern
  (route info, auth decisions, backward-compat redirects)
- apps/admin: already had full logging (unchanged)

Ungated console statements fixed:
- admin/main.ts: error handler, plugin registration, mount errors
- admin/pages/login.vue, register.vue: catch block errors
- admin/pages/events/index.vue: fetch error logging
- admin/pages/wizard-examples: demo form submit logging
- admin/pages/faq.vue: catch block error

All console statements in Crewli-authored code are now gated behind
import.meta.env.DEV — zero console output in production builds.
Vuexy template demo files (views/demos/*) left as-is.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-14 16:43:31 +02:00
parent e53f364929
commit 821bfc5bcf
9 changed files with 45 additions and 14 deletions

View File

@@ -12,13 +12,21 @@ const dashboardRedirects: Record<string, string> = {
}
export function setupGuards(router: Router) {
router.beforeEach(async (to) => {
router.beforeEach(async (to, from) => {
const authStore = useAuthStore()
if (!authStore.isInitialized) {
await authStore.initialize()
}
if (import.meta.env.DEV) {
console.log('🔒 Router Guard:', {
to: to.path,
from: from.path,
isAuthenticated: authStore.isAuthenticated,
})
}
// Hydrate portal data once after auth is confirmed
if (authStore.isAuthenticated) {
const portalStore = usePortalStore()
@@ -28,6 +36,7 @@ export function setupGuards(router: Router) {
// Backward-compat redirects for old dashboard routes
const redirect = dashboardRedirects[to.path]
if (redirect && authStore.isAuthenticated) {
if (import.meta.env.DEV) console.log('🔄 Backward-compat redirect:', to.path, '→', redirect)
return { path: redirect }
}
@@ -36,15 +45,20 @@ export function setupGuards(router: Router) {
// Public routes — no auth check needed
if (!requiresAuth) {
if (authStore.isAuthenticated && guestOnlyPaths.some(p => to.path === p || to.path.startsWith(`${p}/`))) {
if (import.meta.env.DEV) console.log('🔄 Redirecting logged-in user away from login page')
return { path: '/evenementen' }
}
if (import.meta.env.DEV) console.log('✅ Public route, allowing access')
return
}
// Auth required — redirect to login if not authenticated
if (!authStore.isAuthenticated) {
if (import.meta.env.DEV) console.log('🚫 Not authenticated, redirecting to login')
return { path: '/login', query: { to: to.fullPath } }
}
if (import.meta.env.DEV) console.log('✅ Access granted')
})
}