2021-01-02 17:58:24 +07:00
|
|
|
import React, { useState } from "react";
|
|
|
|
|
|
|
|
import { config as faConfig } from "@fortawesome/fontawesome-svg-core";
|
|
|
|
import { BrowserRouter as Router, Route, Switch, Redirect } from "react-router-dom";
|
|
|
|
|
|
|
|
import NotificationBar from "./components/NotificationBar";
|
|
|
|
import NotificationsContext from "./hooks/NotificationsContext";
|
|
|
|
import { Notification } from "./models/Notifications";
|
2019-11-19 06:37:36 +07:00
|
|
|
import {
|
2021-01-02 17:58:24 +07:00
|
|
|
FirstFactorRoute,
|
|
|
|
ResetPasswordStep2Route,
|
|
|
|
ResetPasswordStep1Route,
|
|
|
|
RegisterSecurityKeyRoute,
|
2019-11-19 06:37:36 +07:00
|
|
|
RegisterOneTimePasswordRoute,
|
|
|
|
LogoutRoute,
|
|
|
|
} from "./Routes";
|
2021-01-02 17:58:24 +07:00
|
|
|
import { getBasePath } from "./utils/BasePath";
|
|
|
|
import { getRememberMe, getResetPassword } from "./utils/Configuration";
|
|
|
|
import RegisterOneTimePassword from "./views/DeviceRegistration/RegisterOneTimePassword";
|
|
|
|
import RegisterSecurityKey from "./views/DeviceRegistration/RegisterSecurityKey";
|
|
|
|
import LoginPortal from "./views/LoginPortal/LoginPortal";
|
|
|
|
import SignOut from "./views/LoginPortal/SignOut/SignOut";
|
|
|
|
import ResetPasswordStep1 from "./views/ResetPassword/ResetPasswordStep1";
|
|
|
|
import ResetPasswordStep2 from "./views/ResetPassword/ResetPasswordStep2";
|
|
|
|
|
|
|
|
import "@fortawesome/fontawesome-svg-core/styles.css";
|
2020-04-26 05:12:55 +07:00
|
|
|
|
|
|
|
faConfig.autoAddCss = false;
|
2019-11-19 06:37:36 +07:00
|
|
|
|
|
|
|
const App: React.FC = () => {
|
|
|
|
const [notification, setNotification] = useState(null as Notification | null);
|
2019-12-07 23:40:42 +07:00
|
|
|
|
2019-11-19 06:37:36 +07:00
|
|
|
return (
|
2021-01-02 17:58:24 +07:00
|
|
|
<NotificationsContext.Provider value={{ notification, setNotification }}>
|
2020-07-01 14:16:08 +07:00
|
|
|
<Router basename={getBasePath()}>
|
2020-05-16 06:41:42 +07:00
|
|
|
<NotificationBar onClose={() => setNotification(null)} />
|
|
|
|
<Switch>
|
|
|
|
<Route path={ResetPasswordStep1Route} exact>
|
|
|
|
<ResetPasswordStep1 />
|
|
|
|
</Route>
|
|
|
|
<Route path={ResetPasswordStep2Route} exact>
|
|
|
|
<ResetPasswordStep2 />
|
|
|
|
</Route>
|
|
|
|
<Route path={RegisterSecurityKeyRoute} exact>
|
|
|
|
<RegisterSecurityKey />
|
|
|
|
</Route>
|
|
|
|
<Route path={RegisterOneTimePasswordRoute} exact>
|
|
|
|
<RegisterOneTimePassword />
|
|
|
|
</Route>
|
|
|
|
<Route path={LogoutRoute} exact>
|
|
|
|
<SignOut />
|
|
|
|
</Route>
|
|
|
|
<Route path={FirstFactorRoute}>
|
2021-01-02 17:58:24 +07:00
|
|
|
<LoginPortal rememberMe={getRememberMe()} resetPassword={getResetPassword()} />
|
2020-05-16 06:41:42 +07:00
|
|
|
</Route>
|
|
|
|
<Route path="/">
|
2020-05-21 09:20:55 +07:00
|
|
|
<Redirect to={FirstFactorRoute} />
|
2020-05-16 06:41:42 +07:00
|
|
|
</Route>
|
|
|
|
</Switch>
|
2019-11-19 06:37:36 +07:00
|
|
|
</Router>
|
|
|
|
</NotificationsContext.Provider>
|
|
|
|
);
|
2021-01-02 17:58:24 +07:00
|
|
|
};
|
2019-11-19 06:37:36 +07:00
|
|
|
|
|
|
|
export default App;
|