framework/js/lib/initializers/preload.js

18 lines
525 B
JavaScript
Raw Normal View History

import Session from 'flarum/Session';
/**
* The `session` initializer creates the application session and preloads it
* with data that has been set on the application's `preload` property.
*
* `app.preload.session` should be the same as the response from the /api/token
* endpoint: it should contain `token` and `userId` keys.
*
* @param {App} app
*/
export default function session(app) {
app.session = new Session(
app.preload.session.token,
app.store.getById('users', app.preload.session.userId)
);
}