Call non-relative Object to the current route?

Hi,

As my API need an authentication by custom headers, I would like create a common User object.

$.ajaxSetup({  
    beforeSend: function(jqXHR) {  
        if (User.isAuthenticate()) {  
            jqXHR.setRequestHeader("X-User-ID", Sailfish.UserController.get("id")); // HOWTO?  
            jqXHR.setRequestHeader("X-User-Token", Sailfish.UserController.get("token")); // HOWTO?  
        }  
    }  
});  
  
  
  
Sailfish.Router.map(function() {  
    this.resource("", { path: "/" }, function() {  
        this.resource("product", { path: "/fishes" }, function() {  
            this.route("list");  
            this.route("item", { path: "/:id" });  
        });  
    });  
    this.route("user", { path: "/auth" } );  
    this.route("about");  
});  
  
  
Sailfish.PrivateRoute = Ember.Route.extend({  
    enter: function(controller) {  
        this._super();  
        // HOWTO? 
        // if call(Sailfish.UserController.isAuthenticate()) then transitionTo("/auth") end  
    }  
});  
  
  
Sailfish.UserRoute = Ember.Route.extend({  
    setupController: function(controller) {  
        controller.set("model", Sailfish.User.create());  
    },  
    events: {  
        becomeAuthenticated: function(router) {  
            this.transitionTo("");  
        },  
        forceAuthentication: function(router) {  
            this.transitionTo("/auth");  
        },
        checkAuthentication: function(router) {  
            console.log("check");  
        }  
    }  
});  
  
  
Sailfish.ProductListRoute = Sailfish.PrivateRoute.extend({  
    setupController: function(controller) {  
        controller.loadPage();  
    }  
});  

Sailfish.ProductListController = Ember.ArrayController.extend({  
    content: [],
    loadPage: function() {
        console.log("loadPage");
    }
});  

How can I access to an object controller from anywhere? (from a non-Ember javascript) How can I access to an object controller from a non-relative route? (from Sailfish.PrivateRoute to Sailfish.ProductListController)

Thx

Hi,

This question is more appropriate for StackOverflow, but I think you’d find it very helpful to check out this Embercast on authentication, which will answer a lot of your specific questions and possibly give you some new ideas: http://www.embercasts.com/episodes/client-side-authentication-part-2