Finished login component

Did the following:
 - Extract front-end from component;
 - Added localStorage for remembering API details and access key;
 - Added routing to login component;

Todo:
 - Remove getApi*FromDTO;
 - Create ProtectedRoute to prevent unauthorized entry to /dashboard;
This commit is contained in:
2020-02-19 00:48:30 +01:00
parent 60079a1417
commit ae7d63db35
9 changed files with 254 additions and 62 deletions
+4 -8
View File
@@ -6,18 +6,14 @@ import Login from '../LoginComponent/Login';
import Dashboard from '../DashboardComponent/Dashboard';
export default class App extends React.Component {
componentDidMount() {
if((localStorage.getItem("APILink") !== undefined || localStorage.getItem("APILink") !== '') &&
(localStorage.getItem("AccessToken") !== undefined || localStorage.getItem("AccessToken") !== '')) {
return <Redirect to="/dashboard" />
};
}
render() {
return (
<Switch>
<Route exact path="/" component={Login} />
<Route path="/dashboard" component={Dashboard} />
<Route exact path="/"
component={Login} />
<Route path="/dashboard"
component={Dashboard} />
<Redirect to="/" />
</Switch>
);