equal
deleted
inserted
replaced
1 // see https://gist.github.com/fdidron/ebcf52dc1ed62ff7d80725854d631a9e |
1 // see https://gist.github.com/fdidron/ebcf52dc1ed62ff7d80725854d631a9e |
2 |
2 |
3 import PropTypes from 'prop-types'; |
3 import PropTypes from 'prop-types'; |
4 import React from 'react'; |
4 import React from 'react'; |
5 import { Redirect, Route } from 'react-router'; |
5 import { Redirect, Route } from 'react-router'; |
|
6 import { isAuthenticated } from '../selectors/authSelectors'; |
6 |
7 |
7 const AuthenticatedRoute = ({component, ...props}) => { |
8 const AuthenticatedRoute = ({component, ...props}) => { |
8 |
9 |
9 const { store } = props; |
10 const { store } = props; |
10 const state = store.getState(); |
11 const state = store.getState(); |
11 const isAuthenticated = state.getIn(['authStatus', 'isAuthenticated']); |
|
12 |
12 |
13 if (isAuthenticated) { |
13 if (isAuthenticated(state)) { |
14 return <Route { ...props } component={ component } />; |
14 return <Route { ...props } component={ component } />; |
15 } |
15 } |
16 |
16 |
17 return <Redirect to="/login" />; |
17 return <Redirect to="/login" />; |
18 }; |
18 }; |