Search code examples
authenticationember.jsember-cliember-simple-auth

init and sessionAuthenticated in ApplicationRouteMixin can not be together


I lost my head for this problem: init and sessionAuthenticated in ApplicationRouteMixin can not be together!

In my routes/application.js I have something like this:

import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
import other from '../other';

export default Ember.Route.extend(ApplicationRouteMixin, {

init: function () {
    otherJsImImportingMainFunction();
},

sessionAuthenticated() {
    this.transitionTo('someRoute');
    debugger;
}

actions: {
    ...
}

};

In this situation my code doesn't work.

I authenticate and then sessionAuthenticated() is never called.

If I comment out "init:" it works good.

How to fix this?

I'm doing well importing this way?


Solution

  • NOTE: If you do override init for a framework class like Ember.View, be sure to call this._super(...arguments) in your init declaration! If you don't, Ember may not have an opportunity to do important setup work, and you'll see strange behavior in your application.

    Ember docs