From c0662c80b764350be418af764b1f298bf7c00a55 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Fri, 21 Oct 2022 17:28:17 -0400 Subject: [PATCH] Fix double routing of root path --- src/components/ConnectionRequired.tsx | 3 +++ src/components/appRouter.js | 6 +----- src/routes/index.tsx | 9 +++++++-- src/scripts/routes.js | 6 ------ 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/components/ConnectionRequired.tsx b/src/components/ConnectionRequired.tsx index 01dc4a816c..b9e83ddb0c 100644 --- a/src/components/ConnectionRequired.tsx +++ b/src/components/ConnectionRequired.tsx @@ -96,6 +96,9 @@ const ConnectionRequired: FunctionComponent = ({ } const systemInfo = await infoResponse.json(); if (!systemInfo?.StartupWizardCompleted) { + // Update the current ApiClient + // TODO: Is there a better place to handle this? + ServerConnections.setLocalApiClient(firstConnection.ApiClient); // Bounce to the wizard console.info('[ConnectionRequired] startup wizard is not complete, redirecting there'); navigate(BounceRoutes.StartWizard); diff --git a/src/components/appRouter.js b/src/components/appRouter.js index 52bfac7617..1c67ab976f 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -412,11 +412,7 @@ class AppRouter { if (apiClient && apiClient.isLoggedIn()) { console.debug('[appRouter] user is authenticated'); - if (route.isDefaultRoute) { - console.debug('[appRouter] loading home page'); - this.goHome(); - return; - } else if (route.roles) { + if (route.roles) { this.#validateRoles(apiClient, route.roles).then(() => { callback(); }, this.#beginConnectionWizard.bind(this)); diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 1ab3277e7e..d37fa9a7af 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Route, Routes } from 'react-router-dom'; +import { Navigate, Route, Routes } from 'react-router-dom'; import ConnectionRequired from '../components/ConnectionRequired'; import UserNew from './user/usernew'; @@ -23,7 +23,7 @@ const AppRoutes = () => ( {/* Admin routes */} - }> + }> } /> } /> } /> @@ -32,6 +32,11 @@ const AppRoutes = () => ( } /> + {/* Public routes */} + }> + } /> + + {/* Suppress warnings for unhandled routes */} diff --git a/src/scripts/routes.js b/src/scripts/routes.js index 8367f9b483..0e82513765 100644 --- a/src/scripts/routes.js +++ b/src/scripts/routes.js @@ -492,12 +492,6 @@ import { appRouter } from '../components/appRouter'; serverRequest: true }); - defineRoute({ - path: '/', - autoFocus: false, - isDefaultRoute: true - }); - console.groupEnd('defining core routes'); /* eslint-enable indent */