framework/js/lib/initializers/preload.js
Toby Zerner ab6c03c0cc Massive JavaScript cleanup
- Use JSX for templates
- Docblock/comment everything
- Mostly passes ESLint (still some work to do)
- Lots of renaming, refactoring, etc.

CSS hasn't been updated yet.
2015-07-15 14:01:11 +09:30

18 lines
525 B
JavaScript

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)
);
}