2017-02-13 15:05:30 -08:00
|
|
|
import Ember from 'ember';
|
2017-03-24 21:35:35 -07:00
|
|
|
import ApplicationRouteMixin
|
|
|
|
from 'ember-simple-auth/mixins/application-route-mixin';
|
2017-02-13 15:05:30 -08:00
|
|
|
|
2017-03-24 21:35:35 -07:00
|
|
|
const {
|
|
|
|
Route,
|
2017-03-26 00:56:19 -07:00
|
|
|
run,
|
|
|
|
get,
|
|
|
|
inject: { service }
|
2017-03-24 21:35:35 -07:00
|
|
|
} = Ember;
|
|
|
|
|
|
|
|
export default Route.extend(ApplicationRouteMixin, {
|
2017-03-26 00:56:19 -07:00
|
|
|
// Injected Ember#Service for the current user
|
2017-03-26 13:45:06 -07:00
|
|
|
sessionUser: service('current-user'),
|
2017-03-26 00:56:19 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempt to load the current user
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
|
|
|
beforeModel() {
|
|
|
|
return this._loadCurrentUser();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Augments sessionAuthenticated.
|
|
|
|
* @override ApplicationRouteMixin.sessionAuthenticated
|
|
|
|
*/
|
|
|
|
sessionAuthenticated() {
|
|
|
|
this._super(...arguments);
|
|
|
|
this._loadCurrentUser();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal method to invoke the currentUser service's load method
|
|
|
|
* If an exception occurs during the load for the current user,
|
|
|
|
* invalidate the session.
|
|
|
|
* @returns {Promise<T, V>|RSVP.Promise<any>|Ember.RSVP.Promise<any, any>|Promise.<T>}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_loadCurrentUser() {
|
2017-03-26 13:45:06 -07:00
|
|
|
return get(this, 'sessionUser')
|
2017-03-26 00:56:19 -07:00
|
|
|
.load()
|
|
|
|
.catch(() => get(this, 'session').invalidate());
|
|
|
|
},
|
|
|
|
|
2017-02-13 15:05:30 -08:00
|
|
|
init() {
|
|
|
|
this._super(...arguments);
|
2017-03-24 21:35:35 -07:00
|
|
|
run.scheduleOnce('afterRender', this, 'processLegacyDomOperations');
|
2017-02-13 15:05:30 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
processLegacyDomOperations() {
|
|
|
|
window.legacySearch();
|
2017-03-24 21:35:35 -07:00
|
|
|
// TODO: DSS-6122 Refactor Remove tree legacy operations & references
|
2017-02-13 15:05:30 -08:00
|
|
|
// window.legacyTree();
|
|
|
|
window.legacyMain();
|
|
|
|
}
|
2017-03-24 21:35:35 -07:00
|
|
|
});
|