I’m not sure what you mean by authenticated, is sounds like you already have information to authenticate? Anyways, here is an example of an authenticated route that I extend from to require authentication by using the beforeModel callback:
var AuthenticatedRoute = Ember.Route.extend({
beforeModel: function(transition) {
var isAuthenticated = this.get('session.content.isAuthenticated');
if (!isAuthenticated) {
console.log("No user session, transitioning to login.");
var loginController = this.controllerFor('login');
loginController.set('previousTransition', transition);
this.transitionTo('login');
}
}
});
You might wonder what session is? Well, it is a object that I had ember inject into every route via dependency injection in an initializer. I also save the last transition attempted, so that I can retry it after the user authenticates since they are unauthenticated, so that they return to the route they were previously at.
Example on applying the previous transition after the user has authenticated:
previousTransition = this.get('previousTransition');
if (previousTransition) {
controller.set('previousTransition', null);
previousTransition.retry();
}