Clean up beforeModel(s)

Fixes #20
This commit is contained in:
Matthew Dillon 2015-10-14 13:12:06 -07:00
parent 0dbcd45c4e
commit bcd2bbb4c4
10 changed files with 70 additions and 12 deletions

View file

@ -1,6 +1,15 @@
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel: function(transition) {
this._super(transition);
this.get('session.currentUser').then((user) => {
if (user.get('isReader')) {
this.transitionTo('protected.species.index');
}
});
},
afterModel: function(species) {
if (!species.get('canEdit')) {
this.transitionTo('species.show', species.get('id'));

View file

@ -3,9 +3,11 @@ import Ember from 'ember';
export default Ember.Route.extend({
beforeModel: function(transition) {
this._super(transition);
if (this.get('session.currentUser.role') === 'R') {
this.transitionTo('species.index');
}
this.get('session.currentUser').then((user) => {
if (user.get('isReader')) {
this.transitionTo('protected.species.index');
}
});
},
model: function() {