summaryrefslogtreecommitdiffstats
path: root/client/config/router.js
blob: c859013f5e85495ec980ec83d489c330200f00fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Router.configure({
  loadingTemplate: 'spinner',
  notFoundTemplate: 'notfound',
  layoutTemplate: 'defaultLayout',

  onBeforeAction: function() {
    var options = this.route.options;

    // Redirect logged in users to Boards view when they try to open Login or
    // signup views.
    if (Meteor.userId() && options.redirectLoggedInUsers) {
      return this.redirect('Boards');
    }

    // Authenticated
    if (! Meteor.userId() && options.authenticated) {
      return this.redirect('atSignIn');
    }

    // Reset default sessions
    Session.set('error', false);
    Session.set('warning', false);

    Popup.close();

    this.next();
  }
});