function createRoutes() {
function requireLogin(store) {
return (nextState, replaceState) => {
const { users: { user }} = store.getState();
if (_.isEmpty(user)) { // or any other authentication condition
replaceState({ nextPathname: nextState.location.pathname }, '/');
}
}
}
return (
<ReduxRouter>
<Route path="/" component={LoginPage}/>
<Route path="/login" component={LoginPage}/>
<Route path="/orders" onEnter={requireLogin(store)} component={Main}>
<Route path="/orders(/:filter)" component={HomePage}/>
<Route path="/order/:id/:action" component={OrderPage}/>
<Route path="/order/:id" component={OrderPage}/>
</Route>
</ReduxRouter>
);
}
Created
October 20, 2015 08:54
-
-
Save jmarceli/3e40d1f5cb4d4a6bb6ca to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment