Merge pull request #4084 from thornbill/fix-double-root-routing
This commit is contained in:
commit
bc3e2e0e3f
4 changed files with 11 additions and 13 deletions
|
@ -96,6 +96,9 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
|
||||||
}
|
}
|
||||||
const systemInfo = await infoResponse.json();
|
const systemInfo = await infoResponse.json();
|
||||||
if (!systemInfo?.StartupWizardCompleted) {
|
if (!systemInfo?.StartupWizardCompleted) {
|
||||||
|
// Update the current ApiClient
|
||||||
|
// TODO: Is there a better place to handle this?
|
||||||
|
ServerConnections.setLocalApiClient(firstConnection.ApiClient);
|
||||||
// Bounce to the wizard
|
// Bounce to the wizard
|
||||||
console.info('[ConnectionRequired] startup wizard is not complete, redirecting there');
|
console.info('[ConnectionRequired] startup wizard is not complete, redirecting there');
|
||||||
navigate(BounceRoutes.StartWizard);
|
navigate(BounceRoutes.StartWizard);
|
||||||
|
|
|
@ -412,11 +412,7 @@ class AppRouter {
|
||||||
if (apiClient && apiClient.isLoggedIn()) {
|
if (apiClient && apiClient.isLoggedIn()) {
|
||||||
console.debug('[appRouter] user is authenticated');
|
console.debug('[appRouter] user is authenticated');
|
||||||
|
|
||||||
if (route.isDefaultRoute) {
|
if (route.roles) {
|
||||||
console.debug('[appRouter] loading home page');
|
|
||||||
this.goHome();
|
|
||||||
return;
|
|
||||||
} else if (route.roles) {
|
|
||||||
this.#validateRoles(apiClient, route.roles).then(() => {
|
this.#validateRoles(apiClient, route.roles).then(() => {
|
||||||
callback();
|
callback();
|
||||||
}, this.#beginConnectionWizard.bind(this));
|
}, this.#beginConnectionWizard.bind(this));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
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 ConnectionRequired from '../components/ConnectionRequired';
|
||||||
import UserNew from './user/usernew';
|
import UserNew from './user/usernew';
|
||||||
|
@ -23,7 +23,7 @@ const AppRoutes = () => (
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
{/* Admin routes */}
|
{/* Admin routes */}
|
||||||
<Route path='/' element={<ConnectionRequired isAdminRequired={true} />}>
|
<Route path='/' element={<ConnectionRequired isAdminRequired />}>
|
||||||
<Route path='usernew.html' element={<UserNew />} />
|
<Route path='usernew.html' element={<UserNew />} />
|
||||||
<Route path='userprofiles.html' element={<UserProfiles />} />
|
<Route path='userprofiles.html' element={<UserProfiles />} />
|
||||||
<Route path='useredit.html' element={<UserEdit />} />
|
<Route path='useredit.html' element={<UserEdit />} />
|
||||||
|
@ -32,6 +32,11 @@ const AppRoutes = () => (
|
||||||
<Route path='userpassword.html' element={<UserPassword />} />
|
<Route path='userpassword.html' element={<UserPassword />} />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
{/* Public routes */}
|
||||||
|
<Route path='/' element={<ConnectionRequired isUserRequired={false} />}>
|
||||||
|
<Route index element={<Navigate replace to='/home.html' />} />
|
||||||
|
</Route>
|
||||||
|
|
||||||
{/* Suppress warnings for unhandled routes */}
|
{/* Suppress warnings for unhandled routes */}
|
||||||
<Route path='*' element={null} />
|
<Route path='*' element={null} />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
|
@ -492,12 +492,6 @@ import { appRouter } from '../components/appRouter';
|
||||||
serverRequest: true
|
serverRequest: true
|
||||||
});
|
});
|
||||||
|
|
||||||
defineRoute({
|
|
||||||
path: '/',
|
|
||||||
autoFocus: false,
|
|
||||||
isDefaultRoute: true
|
|
||||||
});
|
|
||||||
|
|
||||||
console.groupEnd('defining core routes');
|
console.groupEnd('defining core routes');
|
||||||
|
|
||||||
/* eslint-enable indent */
|
/* eslint-enable indent */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue