import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';

const { service } = Ember.inject;

export default Ember.Route.extend(ApplicationRouteMixin, {
	sessionAccount: service('session-account'),

	beforeModel() {
		return this._loadCurrentUser();
	},

	model: function() {
		return Ember.Object.create ({
			genres: this.store.findAll('genre'),
			factTypes: this.store.findAll('factType'),
			categories: this.store.findAll('category'),
			topics: this.store.findAll('topic')
		});
	},

	sessionAuthenticated() {
		this._super(...arguments);
		this._loadCurrentUser().catch(() => this.get('session').invalidate());
	},

	_loadCurrentUser() {
		return this.get('sessionAccount').loadCurrentUser();
	}
});

import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';

const { service } = Ember.inject;

export default Ember.Route.extend(ApplicationRouteMixin, {
	session:        service('session'),
	sessionAccount: service('session-account'),

	beforeModel() {
		return this._loadCurrentUser();
	},

	model: function() {
		return Ember.Object.create ({
			genres: this.store.findAll('genre'),
			factTypes: this.store.findAll('factType'),
			categories: this.store.findAll('category'),
			topics: this.store.findAll('topic')
		});
	},

	sessionAuthenticated() {
		this._super(...arguments);
		this._loadCurrentUser().catch(() => this.get('session').invalidate());
	},

	_loadCurrentUser() {
		return this.get('sessionAccount').loadCurrentUser();
	}
});

Fix undefined is not an object for Application route
Fix undefined is not an object for Application route
