2017-05-24 12:19:23 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2017-05-24 01:07:56 +00:00
|
|
|
import withSession from '../lib/with-session';
|
|
|
|
import Login from '../components/Login';
|
2017-05-25 08:11:47 +00:00
|
|
|
import Layout from '../components/Layout';
|
2017-05-24 01:07:56 +00:00
|
|
|
|
|
|
|
const Restricted = (Component) => {
|
|
|
|
const checkAuth = (props) => {
|
2017-05-24 12:19:23 +00:00
|
|
|
return props.isLoggedIn ? <Component {...props} /> : <Login/>
|
2017-05-24 01:07:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return withSession(checkAuth);
|
|
|
|
}
|
|
|
|
|
2017-05-25 08:11:47 +00:00
|
|
|
const Index = Restricted(({session}) => (
|
|
|
|
<div>
|
|
|
|
<Layout session={session} />
|
|
|
|
</div>
|
2017-05-24 01:07:56 +00:00
|
|
|
)
|
2017-05-25 08:11:47 +00:00
|
|
|
)
|
2017-05-24 01:07:56 +00:00
|
|
|
|
2017-05-24 12:19:23 +00:00
|
|
|
Index.propTypes = {
|
|
|
|
session: PropTypes.object.isRequired
|
|
|
|
};
|
2017-05-24 01:07:56 +00:00
|
|
|
|
2017-05-24 12:19:23 +00:00
|
|
|
export default Index;
|