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';
|
|
|
|
import {inject as injectService} from '@ember/service';
|
2015-10-18 21:17:02 +03:00
|
|
|
|
|
|
|
export default SessionService.extend({
|
2016-06-30 13:21:47 +03:00
|
|
|
feature: injectService(),
|
2017-06-08 18:00:10 +03:00
|
|
|
store: injectService(),
|
|
|
|
tour: injectService(),
|
2015-10-18 21:17:02 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
user: computed(function () {
|
2017-01-14 00:14:54 +03:00
|
|
|
return this.get('store').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()
|
|
|
|
];
|
|
|
|
|
|
|
|
return RSVP.all(preloadPromises).then(() => {
|
2016-05-05 17:03:09 +03:00
|
|
|
return authResult;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2015-10-18 21:17:02 +03:00
|
|
|
});
|