Search code examples
ember.jsember-simple-auth

Ember CLI Simple Auth - Cannot read property 'on' of undefined


I've got two Ember 1.11 project that is using Simple-Auth via Ember cli simple auth. The simpler of the two (the basic hello world app) works just fine...in fact it works great (simple auth is pretty awesome). However, the other one (a recently upgraded app) has some sort of initialization error.

My error is:

Error while processing route: receiving.index Cannot read property 'on' of undefined TypeError: Cannot read property 'on' of undefined

And it breaks in ApplicationRouteMixin in the beforeModel function on this line:

_this.get(Configuration.sessionPropertyName).on(event, function(error) {
    Array.prototype.unshift.call(arguments, event);
    var target = routeEntryComplete ? _this : transition;
    target.send.apply(target, arguments);
});

The Configuration.sessionPropertyName is "session" and it obviously can't find it. I haven't been able to recreate it outside of this one project, so any help is appreciated.

Sam


Solution

  • The issue originated from the fact that one of the dependencies (ember-modals) incorrectly instantiated the route:application singleton during the initialization process, preventing further injections. ember-simple-auth normally injects it's session service into route:application, but the attempt was silently failing. This behavior has been fixed in ember-modals since 0.3.0, so upgrading should solve the problem.