Skip to content

Commit

Permalink
fix login page route (#740)
Browse files Browse the repository at this point in the history
* fix login page route

Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>

* also fix default route

Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>

* fix redirect

Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>

---------

Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
  • Loading branch information
Teo Koon Peng authored Aug 22, 2023
1 parent 189227b commit dec13be
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions packages/dashboard/src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import '@fontsource/roboto/500.css';
import '@fontsource/roboto/700.css';
import React from 'react';
import 'react-grid-layout/css/styles.css';
import { Link, Route, Routes, Navigate } from 'react-router-dom';
import { Route, Routes, Navigate } from 'react-router-dom';
import { LoginPage, PrivateRoute } from 'rmf-auth';
import appConfig from '../app-config';
import ResourceManager from '../managers/resource-manager';
Expand Down Expand Up @@ -131,29 +131,24 @@ export default function App(): JSX.Element | null {
</PrivateRoute>
}
/>
<Route
path={CustomRoute1}
element={
<PrivateRoute unauthorizedComponent={loginRedirect} user={user}>
<Link to={DashboardRoute} />
</PrivateRoute>
}
/>
</Routes>
</AppBase>
</RmfApp>
) : (
<Routes>
<Route path={LoginRoute}>
<LoginPage
title={'Dashboard'}
logo="assets/defaultLogo.png"
onLoginClick={() => authenticator.login(`${window.location.origin}${DashboardRoute}`)}
/>
</Route>
<Route>
<Link to={LoginRoute} />
</Route>
<Route
path={LoginRoute}
element={
<LoginPage
title={'Dashboard'}
logo="assets/defaultLogo.png"
onLoginClick={() =>
authenticator.login(`${window.location.origin}${DashboardRoute}`)
}
/>
}
/>
<Route path="*" element={<Navigate to={LoginRoute} />} />
</Routes>
)}
</ResourcesContext.Provider>
Expand Down

0 comments on commit dec13be

Please sign in to comment.