You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setting up routes, I generally use an auth function to make sure the user is logged in, if not redirect to '/' so they can login. However using FlowRouter.notFound does not trigger as expected:
function ifAuth(context, redirect) {
console.log('ifAuth: check for user:', Meteor.userId());
if (!Meteor.userId()) {
console.log('No Meteor user, redirect to /');
redirect('/');
}
}
FlowRouter.notFound = {
name: 'not-found',
triggersEnter: [ifAuth],
action: function() {
console.log('page not found?')
mount(MainLayoutContainer, {
children: <NotFoundPage />
});
}
};
If I go to a route like '/asdf' it will log 'page not found' but not 'ifAutho: check for user:'
What I have to do instead is set a catch-all (like in most other routers) in order to run the ifAuth on a route not found:
Setting up routes, I generally use an auth function to make sure the user is logged in, if not redirect to '/' so they can login. However using FlowRouter.notFound does not trigger as expected:
If I go to a route like '/asdf' it will log 'page not found' but not 'ifAutho: check for user:'
What I have to do instead is set a catch-all (like in most other routers) in order to run the ifAuth on a route not found:
The text was updated successfully, but these errors were encountered: