I have a number of routes which are extended from a base route.
In the base route I handle the beforeModel() hook, and based on the transition start and transition end I want to allow/disallow the transition to take place.
Figured it out in the meantime and would like to share my glorious discovery with anyone else interested:
/* app/route/authenticate.js */
export default Ember.Route.extend({
...
beforeModel: function(transition) {
var routeName = this.controllerFor('application').get('currentRouteName');
var pathName = this.controllerFor('application').get('currentPath');
var targetName = transition.targetName;
var isAdmin = controller.get('currentUser.is_admin');
if (isAdmin) {
// This guy can do anything.
...
} else {
// Not admin, some restrictions may apply.
var blacklist = [ 'secret', 'not-allowed' ];
if ( blacklist.indexOf(targetName) != -1) {
// Not allowed.
transition.abort();
this.transitionTo('/not-found');
}
}
...
},
...
});
In another route where you want to enforce this authentication, you need to declare it as follows: