In this code; I except that the router go to the home page automatically when the user is log in
Meteor.startup(() => {
const requireAuth = function requireAuth(nextState, replace) {
if (!Meteor.user()) {
replace({
pathname: '/login',
state: { nextPathname: nextState.location.pathname }
})
}
}
const requireNotAuthed = function requireNotAuthed(nextState, replace) {
if (Meteor.user()) {
replace({
pathname: '/',
})
}
}
render(
<Router history = {browserHistory}>
<Route path="/" component={ Navigation } onChange={requireAuth}>
<IndexRoute component={ App } onEnter={requireAuth} />
<Route path="/one" component={ One } onEnter={requireAuth} />
<Route path="/two" component={ Two } onEnter={requireAuth} />
<Route path="/login" component={Login} />
<Route path="*" component={ Not } onEnter={requireAuth} />
</Route>
</Router>,
document.getElementById('app'));
});
unfortunatly, it does not and the user should on Home icon to go to it;
Did I miss something on my code ??