summaryrefslogtreecommitdiffstats
path: root/client/config/router.js
blob: d4bc3c4fd3953be19e59542df57fafc24eab30eb (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
29
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);

    Tracker.nonreactive(function() {
      EscapeActions.executeLowerThan(40);
    });

    this.next();
  }
});