2017-06-08 18:00:10 +03:00
|
|
|
import RSVP from 'rsvp';
|
2017-05-29 21:50:03 +03:00
|
|
|
import SessionService from 'ember-simple-auth/services/session';
|
2017-08-22 10:53:26 +03:00
|
|
|
import {computed} from '@ember/object';
|
2017-10-30 12:38:01 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2015-10-18 21:17:02 +03:00
|
|
|
|
|
|
|
export default SessionService.extend({
|
2017-10-30 12:38:01 +03:00
|
|
|
feature: service(),
|
2019-01-02 12:58:55 +03:00
|
|
|
dataStore: service('store'), // SessionService.store already exists
|
2017-10-30 12:38:01 +03:00
|
|
|
tour: service(),
|
2015-10-18 21:17:02 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
user: computed(function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
return this.get('dataStore').queryRecord('user', {id: 'me'});
|
2016-05-05 17:03:09 +03:00
|
|
|
}),
|
|
|
|
|
|
|
|
authenticate() {
|
|
|
|
return this._super(...arguments).then((authResult) => {
|
2017-06-08 18:00:10 +03:00
|
|
|
// TODO: remove duplication with application.afterModel
|
|
|
|
let preloadPromises = [
|
|
|
|
this.get('feature').fetch(),
|
|
|
|
this.get('tour').fetchViewed()
|
|
|
|
];
|
|
|
|
|
2018-01-05 18:38:23 +03:00
|
|
|
return RSVP.all(preloadPromises).then(() => authResult);
|
2016-05-05 17:03:09 +03:00
|
|
|
});
|
|
|
|
}
|
2015-10-18 21:17:02 +03:00
|
|
|
});
|