travis-web/app/routes/basic.js
2016-01-04 13:15:14 +01:00

33 lines
800 B
JavaScript

import config from 'travis/config/environment';
import Ember from 'ember';
export default Ember.Route.extend({
activate() {
if (this.routeName !== 'error') {
this.controllerFor('error').set('layoutName', null);
}
return this._super.apply(this, arguments);
},
beforeModel(transition) {
if (!this.signedIn()) {
this.auth.autoSignIn();
}
if (!this.signedIn() && this.get('needsAuth')) {
this.auth.set('afterSignInTransition', transition);
return Ember.RSVP.reject("needs-auth");
} else {
return this._super.apply(this, arguments);
}
},
signedIn() {
return this.controllerFor('currentUser').get('model');
},
needsAuth: function() {
// on pro, we need to auth on every route
return config.pro;
}.property()
});