diff -r d48a74232d22 -r 0a1d6560acac client/src/misc/AuthenticatedRoute.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/misc/AuthenticatedRoute.js Thu Jun 29 12:05:09 2017 +0200 @@ -0,0 +1,27 @@ +// see https://gist.github.com/fdidron/ebcf52dc1ed62ff7d80725854d631a9e + +import PropTypes from 'prop-types'; +import React from 'react'; +import { Redirect, Route } from 'react-router'; + +const AuthenticatedRoute = ({component, ...props}) => { + + const { store } = props; + const state = store.getState(); + const isAuthenticated = state.isAuthenticated; + + if (isAuthenticated) { + return ; + } + + return ; +}; + +AuthenticatedRoute.propTypes = { + component: PropTypes.oneOfType([ + PropTypes.element, + PropTypes.func + ]) +}; + +export default AuthenticatedRoute;