framework/ember/app/initializers/preload-data.js
Toby Zerner a62e04f956 Upgrade to JSON-API RC3 + latest version of tobscure/json-api
Note: npm source for ember-json-api changed to a fork, but I still had
to apply a custom change to get polymorphic relationships to work (see
https://github.com/kurko/ember-json-api/pull/71#issuecomment-85257281)
2015-03-24 15:04:24 +10:30

21 lines
588 B
JavaScript

import Ember from 'ember';
export default {
name: 'preload-data',
after: 'store',
initialize: function(container) {
var store = container.lookup('store:main');
if (!Ember.isEmpty(FLARUM_DATA)) {
store.pushPayload({included: FLARUM_DATA});
}
if (!Ember.isEmpty(FLARUM_SESSION)) {
FLARUM_SESSION.user = store.getById('user', FLARUM_SESSION.userId);
container.lookup('simple-auth-session:main').setProperties({
isAuthenticated: true,
authenticator: 'authenticator:flarum',
content: FLARUM_SESSION
});
}
}
};