1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-23 00:00:02 +01:00
VILLASweb/app/routes/application.js
Markus Grigull 548bbb5e15 Add project create, delete and store in user data
Change adapter and serializer to REST api.
Add session-user to get logged-in user in every controller/route
Change models to async relationships, this way the data is only loaded when
requested.
2016-06-27 23:22:05 +02:00

28 lines
643 B
JavaScript

import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
const { service } = Ember.inject;
export default Ember.Route.extend(ApplicationRouteMixin, {
sessionUser: service('session-user'),
beforeModel() {
return this._loadCurrentUser();
},
sessionAuthenticated() {
this._loadCurrentUser().then(() => {
this.transitionTo('/');
}).catch(() => this.get('session').invalidate());
},
_loadCurrentUser() {
return this.get('sessionUser').loadCurrentUser();
},
actions: {
invalidateSession() {
this.get('session').invalidate();
}
}
});