This repository has been archived on 2025-03-30. You can view files and clone it, but cannot push or open issues or pull requests.
hymenobacterdotinfo/app/pods/protected/characteristics/edit/route.js
Matthew Dillon bcd2bbb4c4 Clean up beforeModel(s)
Fixes #20
2015-10-14 13:12:06 -07:00

24 lines
688 B
JavaScript

import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
export default Ember.Route.extend(AuthenticatedRouteMixin, {
beforeModel: function(transition) {
this._super(transition);
this.get('session.currentUser').then((user) => {
if (user.get('isReader')) {
this.transitionTo('protected.characteristics.index');
}
});
},
model: function(params) {
return this.store.findRecord('characteristic', params.characteristic_id, { reload: true });
},
afterModel: function(model) {
if (!model.get('canEdit')) {
this.transitionTo('characteristics.show', model.get('id'));
}
},
});