Simple-auth session in model


#1

Is there a way to access the session object from inside of the model?


#2

Possible solution which works:

// TODO: This can be removed when upgraded to Ember 2.4+
// Unfortunately, simple-auth doesn't inject the session into model, so
// in order to do that, I created my own initializer. After simple-auth
// is initialized, I do it myself.
export function initialize(container, application) {
    application.inject('model', 'session', 'simple-auth-session:main');
}

export default {
    name: 'inject-session-in-model',
    after: ['simple-auth'],
    initialize
};

#3

jup or just use service injection per model if its not required everywhere


#4

Sure, but session is kind of an important global setting, so I purposely make it available in all models.