ElevatedAccess Mixin
This commit is contained in:
parent
58cbf4027d
commit
76942a10d0
4 changed files with 44 additions and 22 deletions
|
@ -1,23 +1,10 @@
|
|||
import Ember from 'ember';
|
||||
import ElevatedAccess from '../../../../mixins/elevated-access';
|
||||
|
||||
const { Route, inject: { service } } = Ember;
|
||||
|
||||
export default Route.extend({
|
||||
currentUser: service('session-account'),
|
||||
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
this.get('currentUser.account').then((user) => {
|
||||
if (user.get('isReader')) {
|
||||
this.transitionTo('protected.species.index');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
afterModel: function(model) {
|
||||
if (!model.get('canEdit')) {
|
||||
this.transitionTo('species.show', model.get('id'));
|
||||
}
|
||||
},
|
||||
const { Route } = Ember;
|
||||
|
||||
export default Route.extend(ElevatedAccess, {
|
||||
// Required for ElevatedAccess mixin
|
||||
fallbackRouteBefore: 'protected.species.index',
|
||||
fallbackRouteAfter: 'protected.species.show',
|
||||
});
|
||||
|
|
Reference in a new issue