Issue to be chalanged
FridMehdi opened this issue · 0 comments
FridMehdi commented
hello @cornflourblue for your efforts,
I was inspired by this example , but I noticed that something is missing.
the privateRoute is not really functional, you are using the localstorage to check if user was logged.
#the problem is if I put some dummy-data without fetching my api in localstorage, I will get access to private route(redux-system usage ?)
my question do you have a safe way to resrict access to privates routes and precheck if data is correct, if local storage was manually updated or inserted(corrupted data)
export const PrivateRoute = ({ component: Component, ...rest }) => (
<Route {...rest} render={props => (
localStorage.getItem('user')
? <Component {...props} />
: <Redirect to={{ pathname: '/login', state: { from: props.location } }} />
)} />
)