mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
23b2ac07d8
closes #3446, closes #3086 - Authors can only ever get to their own posts - Editors only ever see authors in the user list
32 lines
990 B
JavaScript
32 lines
990 B
JavaScript
import PaginationRouteMixin from 'ghost/mixins/pagination-route';
|
|
|
|
var paginationSettings = {
|
|
page: 1,
|
|
limit: 20,
|
|
status: 'all'
|
|
};
|
|
|
|
var UsersIndexRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, PaginationRouteMixin, {
|
|
setupController: function (controller, model) {
|
|
this._super(controller, model);
|
|
this.setupPagination(paginationSettings);
|
|
},
|
|
|
|
model: function () {
|
|
var self = this;
|
|
return this.store.find('user', 'me').then(function (currentUser) {
|
|
if (currentUser.get('isEditor')) {
|
|
// Editors only see authors in the list
|
|
paginationSettings.role = 'Author';
|
|
}
|
|
return self.store.filter('user', paginationSettings, function (user) {
|
|
if (currentUser.get('isEditor')) {
|
|
return user.get('isAuthor');
|
|
}
|
|
return true;
|
|
});
|
|
});
|
|
}
|
|
});
|
|
|
|
export default UsersIndexRoute;
|