2019-12-07 16:40:42 +00:00
|
|
|
import React, { useState, useEffect } from 'react';
|
2019-11-18 23:37:36 +00:00
|
|
|
import {
|
|
|
|
BrowserRouter as Router, Route, Switch, Redirect
|
|
|
|
} from "react-router-dom";
|
|
|
|
import ResetPasswordStep1 from './views/ResetPassword/ResetPasswordStep1';
|
|
|
|
import ResetPasswordStep2 from './views/ResetPassword/ResetPasswordStep2';
|
|
|
|
import RegisterSecurityKey from './views/DeviceRegistration/RegisterSecurityKey';
|
|
|
|
import RegisterOneTimePassword from './views/DeviceRegistration/RegisterOneTimePassword';
|
|
|
|
import {
|
|
|
|
FirstFactorRoute, ResetPasswordStep2Route,
|
|
|
|
ResetPasswordStep1Route, RegisterSecurityKeyRoute,
|
|
|
|
RegisterOneTimePasswordRoute,
|
|
|
|
LogoutRoute,
|
|
|
|
} from "./Routes";
|
|
|
|
import LoginPortal from './views/LoginPortal/LoginPortal';
|
|
|
|
import NotificationsContext from './hooks/NotificationsContext';
|
|
|
|
import { Notification } from './models/Notifications';
|
|
|
|
import NotificationBar from './components/NotificationBar';
|
|
|
|
import SignOut from './views/LoginPortal/SignOut/SignOut';
|
2019-12-07 16:40:42 +00:00
|
|
|
import { useConfiguration } from './hooks/Configuration';
|
2020-04-25 22:12:55 +00:00
|
|
|
import '@fortawesome/fontawesome-svg-core/styles.css'
|
2020-05-21 02:20:55 +00:00
|
|
|
import { config as faConfig } from '@fortawesome/fontawesome-svg-core';
|
|
|
|
import { useBasePath } from './hooks/BasePath';
|
2020-04-25 22:12:55 +00:00
|
|
|
|
|
|
|
faConfig.autoAddCss = false;
|
2019-11-18 23:37:36 +00:00
|
|
|
|
|
|
|
const App: React.FC = () => {
|
|
|
|
const [notification, setNotification] = useState(null as Notification | null);
|
2019-12-07 16:40:42 +00:00
|
|
|
const [configuration, fetchConfig, , fetchConfigError] = useConfiguration();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (fetchConfigError) {
|
|
|
|
console.error(fetchConfigError);
|
|
|
|
}
|
|
|
|
}, [fetchConfigError]);
|
|
|
|
|
|
|
|
useEffect(() => { fetchConfig() }, [fetchConfig]);
|
|
|
|
|
2019-11-18 23:37:36 +00:00
|
|
|
return (
|
|
|
|
<NotificationsContext.Provider value={{ notification, setNotification }} >
|
2020-05-21 02:20:55 +00:00
|
|
|
<Router basename={useBasePath()}>
|
2020-05-15 23:41:42 +00: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}>
|
|
|
|
<LoginPortal
|
|
|
|
rememberMe={configuration?.remember_me === true}
|
|
|
|
resetPassword={configuration?.reset_password === true} />
|
|
|
|
</Route>
|
|
|
|
<Route path="/">
|
2020-05-21 02:20:55 +00:00
|
|
|
<Redirect to={FirstFactorRoute} />
|
2020-05-15 23:41:42 +00:00
|
|
|
</Route>
|
|
|
|
</Switch>
|
2019-11-18 23:37:36 +00:00
|
|
|
</Router>
|
|
|
|
</NotificationsContext.Provider>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default App;
|