diff --git a/app/pods/protected/users/show/controller.js b/app/pods/protected/users/show/controller.js index 3c6c549..26c243d 100644 --- a/app/pods/protected/users/show/controller.js +++ b/app/pods/protected/users/show/controller.js @@ -1,9 +1,9 @@ import Ember from 'ember'; +import DeleteModel from '../../../../mixins/delete-model'; -export default Ember.Controller.extend({ - currentUser: Ember.inject.service('session-account'), +const { Controller } = Ember; - isUser: Ember.computed('model.id', 'currentUser.account.id', function() { - return this.get('model.id') === this.get('currentUser.account.id'); - }), +export default Controller.extend(DeleteModel, { + // Required for DeleteModel mixin + transitionRoute: 'protected.index', }); diff --git a/app/pods/protected/users/show/route.js b/app/pods/protected/users/show/route.js index a0c9fd9..798787d 100644 --- a/app/pods/protected/users/show/route.js +++ b/app/pods/protected/users/show/route.js @@ -1,21 +1,25 @@ import Ember from 'ember'; -export default Ember.Route.extend({ - currentUser: Ember.inject.service('session-account'), +const { Route, inject: { service } } = Ember; +export default Route.extend({ + currentUser: service('session-account'), + + // Not using ElevatedAccess Mixin because the rules for viewing user accounts + // is slightly different. beforeModel: function(transition) { this._super(transition); - this.get('currentUser.account').then((currentUser) => { - let user_id = transition.params['protected.users.show'].user_id; - if (!currentUser.get('isAdmin') && currentUser.get('id') !== user_id) { + this.get('currentUser.account').then((user) => { + const user_id = transition.params['protected.users.show'].user_id; + if (!user.get('isAdmin') && user.get('id') !== user_id) { this.transitionTo('protected.users.index'); } }); }, model: function(params) { - return this.store.findRecord('user', params.user_id, { reload: true }); + return this.store.findRecord('user', params.user_id); }, }); diff --git a/app/pods/protected/users/show/template.hbs b/app/pods/protected/users/show/template.hbs index ca89688..a8648c4 100644 --- a/app/pods/protected/users/show/template.hbs +++ b/app/pods/protected/users/show/template.hbs @@ -1,53 +1,5 @@ -