mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-23 00:00:02 +01:00

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.
28 lines
643 B
JavaScript
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();
|
|
}
|
|
}
|
|
});
|