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/users/edit/route.js
2015-11-06 11:20:28 -07:00

26 lines
682 B
JavaScript

import Ember from 'ember';
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);
let user_id = transition.params['protected.users.edit'].user_id;
this.get('currentUser.account').then((user) => {
if (user.get('id') !== user_id && !user.get('isAdmin')) {
this.transitionTo('protected.users.index');
}
});
},
model: function(params) {
return this.store.findRecord('user', params.user_id);
},
});