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:
@@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user