From 70928d3968e959766719989d6f06a5043c3c3288 Mon Sep 17 00:00:00 2001 From: Isaac Hill <71404865+isaachilly@users.noreply.github.com> Date: Tue, 10 Nov 2026 08:59:27 +0100 Subject: [PATCH] Enable apiAithRoutes so redirect ILG to /api/login when no token is present App only mounts once the session has loaded. --- InfoLogger/config-default.js | 1 + InfoLogger/src/index.js | 42 ++++++++++++++++++---------------- InfoLogger/test/test-config.js | 1 + 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/InfoLogger/config-default.js b/InfoLogger/config-default.js index fc67c524f..cb8efe7c1 100644 --- a/InfoLogger/config-default.js +++ b/InfoLogger/config-default.js @@ -23,6 +23,7 @@ module.exports = { tls: false, allow: true, name: 'ILG', + apiAuthRoutes: true, }, // optional data source, comment object if not used diff --git a/InfoLogger/src/index.js b/InfoLogger/src/index.js index eda63f93a..52fcd05b8 100644 --- a/InfoLogger/src/index.js +++ b/InfoLogger/src/index.js @@ -13,7 +13,7 @@ */ import { sessionService } from '/js/src/index.js'; -sessionService.loadAndHideParameters(); +const isSessionLoaded = sessionService.loadAndHideParameters({ loginUrl: '/api/login' }); // Expose sessionService to interact with it the browser's console window.sessionService = sessionService; @@ -23,25 +23,27 @@ import { mount, StatefulComponent } from '/js/src/index.js'; import view from './view.js'; import Model from './Model.js'; -// Start application -const model = new Model(); -const debug = true; // shows when redraw is done -StatefulComponent.useRenderer(model); // Register the model for the stateful components -let currentView = view; -mount(document.body, (model) => currentView(model), model, debug); +// Start application, unless the browser is being redirected to the login +if (isSessionLoaded) { + const model = new Model(); + const debug = true; // shows when redraw is done + StatefulComponent.useRenderer(model); // Register the model for the stateful components + let currentView = view; + mount(document.body, (model) => currentView(model), model, debug); -// Expose model to interact with it the browser's console -window.model = model; + // Expose model to interact with it the browser's console + window.model = model; -// Dev only, stripped from the prod build. On an edit, Vite walks up from the changed file through its importers -// until it finds an accept() for it. -// Edits under view.js stop here, we swap in the new view and redraw with the same model, so state is preserved here. -// Edits under Model.js reach this file via Model.js, which is not accepted, so Vite just reloads the whole page. -// Unlike React/Pinia, our models keep state as fields on instances of the old class, next to observers set up in -// their constructors, so they can't be swapped in place. -if (import.meta.hot) { - import.meta.hot.accept('./view.js', (newModule) => { - currentView = newModule.default; - model.notify(); - }); + // Dev only, stripped from the prod build. On an edit, Vite walks up from the changed file through its importers + // until it finds an accept() for it. + // Edits under view.js stop here, we swap in the new view and redraw with the same model, so state is preserved here. + // Edits under Model.js reach this file via Model.js, which is not accepted, so Vite just reloads the whole page. + // Unlike React/Pinia, our models keep state as fields on instances of the old class, next to observers set up in + // their constructors, so they can't be swapped in place. + if (import.meta.hot) { + import.meta.hot.accept('./view.js', (newModule) => { + currentView = newModule.default; + model.notify(); + }); + } } diff --git a/InfoLogger/test/test-config.js b/InfoLogger/test/test-config.js index 947731aa8..15edb0a1e 100644 --- a/InfoLogger/test/test-config.js +++ b/InfoLogger/test/test-config.js @@ -22,6 +22,7 @@ module.exports = { tls: false, allow: true, name: 'TST', + apiAuthRoutes: true, }, infoLoggerServer: { host: 'localhost',