2015-07-15 12:30:11 +08:00
|
|
|
import Session from 'flarum/Session';
|
2015-07-07 13:59:21 +08:00
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
);
|
2015-07-07 13:59:21 +08:00
|
|
|
}
|