router.js 657 B

12345678910111213141516171819202122232425262728
  1. Router.configure({
  2. loadingTemplate: 'spinner',
  3. notFoundTemplate: 'notfound',
  4. layoutTemplate: 'defaultLayout',
  5. onBeforeAction: function() {
  6. var options = this.route.options;
  7. // Redirect logged in users to Boards view when they try to open Login or
  8. // signup views.
  9. if (Meteor.userId() && options.redirectLoggedInUsers) {
  10. return this.redirect('Boards');
  11. }
  12. // Authenticated
  13. if (! Meteor.userId() && options.authenticated) {
  14. return this.redirect('atSignIn');
  15. }
  16. // Reset default sessions
  17. Session.set('error', false);
  18. Session.set('warning', false);
  19. Popup.close();
  20. this.next();
  21. }
  22. });