title: Backbone router: Authentication redirect
body: <p>In order to trigger an event that triggers before a route callback is executed, I use the following plugin:  </p>
  
  <p><a href="https://github.com/boazsender/backbone.routefilter" rel="nofollow">https://github.com/boazsender/backbone.routefilter</a></p>
  
  <p>This works well.<br>
  However, I want to redirect the user to a certain route (with trigger set to true) after checking if the user is currently authenticated in the back end.  </p>
  
  <p>I'm currently doing this with an Ajax request, but obviously this brings me trouble.<br>
  In the below code, the ajax callback will only get fired after the 'home' callback from the router was already executed (or any other route for that matter).<br>
  How can I get this done?  </p>
  
  <p>I have the following code:  </p>
  
  <pre><code>var Router = Backbone.Router.extend({ 
  
      /* --- 1. Route management --- */ 
  
      routes: { 
          '': 'landing_page', 
          '(/)login': 'login', 
          '(/)home': 'home', 
          '*actions': 'defaultAction', 
          }, 
      before: function(route, params) { 
          var getAuthStatus = APP.controllers.auth_controller.isLogged(); 
          var self = this; 
  
          $.when(getAuthStatus).then(function(response){ 
              var auth_status = Object.keys(response.success)[0]; 
              if(auth_status === 'guest'){ 
                  console.log(auth_status); 
                  self.navigate("login", {trigger: true}); 
              } 
          }); 
      }
  }); 
  </code></pre>
  
  <p>The ajax request: </p>
  
  <pre><code>Auth_controller.prototype.isLogged = function(){ 
      //Check if the user is authenticated 
      var getAuthStatus = this.auth_model.fetch(); 
      return getAuthStatus; 
  }; 
  </code></pre>
  
  <p>Edit: 'return false' in the 'before' method will stop executing the callback, but in that case, the callback for the 'login' route will not get triggered either. This is not the purpose. </p>