mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-20 01:03:23 +03:00
74549ddc59
closes #3446, closes #3086 - Authors can only ever get to their own posts - Editors only ever see authors in the user list
25 lines
1000 B
JavaScript
25 lines
1000 B
JavaScript
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
|
|
|
var PostsIndexRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, {
|
|
// This route's only function is to determine whether or not a post
|
|
// exists to be used for the content preview. It has a parent resource (Posts)
|
|
// that is responsible for populating the store.
|
|
beforeModel: function () {
|
|
var self = this,
|
|
// the store has been populated so we can work with the local copy
|
|
post = this.store.all('post').get('firstObject');
|
|
|
|
if (post) {
|
|
return this.store.find('user', 'me').then(function (user) {
|
|
if (user.get('isAuthor') && post.isAuthoredByUser(user)) {
|
|
// do not show the post if they are an author but not this posts author
|
|
return;
|
|
}
|
|
|
|
return self.transitionTo('posts.post', post);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
export default PostsIndexRoute; |