From e3fe3ae881d9554430d08d08e1b110ecfc6cf6f1 Mon Sep 17 00:00:00 2001 From: Hawk Date: Wed, 13 May 2020 00:26:06 +0200 Subject: [PATCH] fixed issue with double login close #53 --- frontend/src/App.js | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.js b/frontend/src/App.js index a60257f..237a6f9 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -49,6 +49,44 @@ class ProtectedRoute extends Component { ) } } + +class CheckRoute extends Component { + constructor(props) { + super(props); + this.state = { auth: null }; + } + + async componentWillMount() { + const url = "/simcompanies/API/testlogin"; + const response = await fetch(url); + if (response.status == "200") { + this.setState({ + auth: true + }); + } else { + this.setState({ + auth: false + }); + } + } + + render() { + const { component: Component, ...props } = this.props; + return ( + this.state.auth === null ? + "Loading..." : + ( + this.state.auth ? + : + + )} + /> + ) + } +} + class App extends Component { render() { @@ -71,8 +109,8 @@ class App extends Component { - - + + -- 2.49.1