Permissions

This commit is contained in:
Tarang Patel 2013-11-11 21:15:04 +02:00
parent fdab645c15
commit c56c079cf2

View file

@ -134,8 +134,9 @@ Meteor.methods({
// decrement post count
var post = Posts.findOne({_id: postId});
Meteor.users.update({_id: post.userId}, {$inc: {postCount: -1}});
if(!Meteor.userId() || !canEditById(Meteor.userId(), post)) throw new Meteor.Error(606, 'You need permission to edit or delete a post');
Meteor.users.update({_id: post.userId}, {$inc: {postCount: -1}});
Posts.remove(postId);
}
});