From 6021b351a3f32e5b46bdfc989d537ccbafad0bbe Mon Sep 17 00:00:00 2001 From: Javier Mengual Date: Fri, 16 Jan 2026 22:04:29 +0100 Subject: [PATCH] Enhance router logic to support DEV_MODE for easier testing and navigation --- src/router.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/router.js b/src/router.js index 5db2e38..a5f7380 100644 --- a/src/router.js +++ b/src/router.js @@ -3,14 +3,17 @@ import { renderLoginPage } from './pages/LoginPage.js'; import { createSidebar } from './components/Sidebar.js'; import { getAvailablePages, getPageByRoute } from './pages/pagesRegistry.js'; +// 🔧 Modo DEV: cambiar a false para activar login +const DEV_MODE = false; + export function initRouter() { const app = document.querySelector('#app'); function navigate() { - const hash = window.location.hash || '#login'; + const hash = window.location.hash || (DEV_MODE ? '#dashboard' : '#login'); const route = hash.substring(1); // Remove the # symbol - if (!auth.checkAuth() && hash !== '#login') { + if (!DEV_MODE && !auth.checkAuth() && hash !== '#login') { window.location.hash = '#login'; return; } @@ -18,7 +21,8 @@ export function initRouter() { app.innerHTML = ''; // For authenticated routes, add sidebar and main content wrapper - if (auth.checkAuth() && hash !== '#login') { + const isAuthenticated = DEV_MODE || auth.checkAuth(); + if (isAuthenticated && hash !== '#login') { const layout = document.createElement('div'); layout.className = 'app-layout'; @@ -39,7 +43,7 @@ export function initRouter() { return; } - if (page.requiresAuth && !auth.checkAuth()) { + if (!DEV_MODE && page.requiresAuth && !auth.checkAuth()) { window.location.hash = '#login'; return; }