anton-b
09/10/2017, 1:55 AM/
and /authenticate
- if the user tries to access /
without being authenticated, they will be redirected to /authenticate
this works from Chrome on my mac and in iOS. However, I can't access /authenticate
directly from iOS, then I get a 404, while it still works fine in Chrome.anton-b
09/10/2017, 10:20 AMagartha
09/10/2017, 11:14 PMagartha
09/10/2017, 11:15 PManton-b
09/11/2017, 12:41 PManton-b
09/11/2017, 12:42 PMclass App extends Component {
_isLoggedIn = () => {
return localStorage.getItem(GC_AUTH_TOKEN);
}
render() {
const Routes = props => (
this._isLoggedIn() ?
<AuthenticatedRoutes userdata={this.props.data.user} /> :
<NotAuthenticatedRoutes />
);
if (this.props.data.loading) {
return (
<Loading />
);
}
return(
<Routes />
);
}
}
routes.js
export const AuthenticatedRoutes = () => (
<div>
<Switch>
<Route exact path='/' component={Header} />
<Route path='/createhandler' component={CreateHandlerPage} />
<Route path='/newoperator' component={() => <h1>NewOperatorPage</h1>}/>
<Route path='/:operatorslug' component={() => <h1>OperatorPage</h1>}/>
<Route render={() => <h1>Page not found</h1>}/>
</Switch>
</div>
);
export const NotAuthenticatedRoutes = () => (
<div>
<Switch>
<Route path='/authenticate' component={AuthenticatePage} />
<Redirect to='/authenticate' />
</Switch>
</div>
);
agartha
09/11/2017, 12:50 PManton-b
09/11/2017, 12:55 PMagartha
09/11/2017, 12:58 PManton-b
09/11/2017, 1:03 PManton-b
09/11/2017, 1:08 PMagartha
09/11/2017, 1:08 PManton-b
09/11/2017, 1:09 PMagartha
09/11/2017, 1:10 PMagartha
09/11/2017, 1:13 PMagartha
09/11/2017, 1:14 PManton-b
09/11/2017, 1:22 PManton-b
09/11/2017, 1:26 PManton-b
09/11/2017, 1:27 PMagartha
09/11/2017, 1:27 PM