meteor - How to redirect after user has just logged in or just logged out -


it seems deps.autorun way go router.go doesn't seem work within deps.autorun.

here example 3 routes: index, signin , dashboard:

router.configure({layouttemplate: 'layout'});  router.map(function() {   this.route('index', {path: '/'});   this.route('signin');   this.route('dashboard'); });  var mustbesignedin = function(pause) {   if (!(meteor.user() || meteor.loggingin())) {     router.go('signin');   } else {     this.next();   } };  var gotodashboard = function(pause) {   if (meteor.user()) {     router.go('dashboard');   } else {     this.next();   } };  router.onbeforeaction(mustbesignedin, {except: ['signin']}); router.onbeforeaction(gotodashboard, {only: ['index']}); 

if user on index page , logged in, automatically routed dashboard page. on page except signin, if user not logged in routed signin page. onbeforeaction reactive these rules enforced if user logs in or out.

of course routes different, example illustrates 1 way make work iron-router.

also see using hooks section of iron-router guide.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -