Skip to content

Instantly share code, notes, and snippets.

@varavut
Last active January 24, 2016 12:24
Show Gist options
  • Save varavut/7e185ac0a44d349a4f71 to your computer and use it in GitHub Desktop.
Save varavut/7e185ac0a44d349a4f71 to your computer and use it in GitHub Desktop.
if (Meteor.isServer) {
Threads.allow({
insert: function (userId, doc) {
if(!userId)
throw new Meteor.Error('Unauthorized', 'Please login before perform an action');
check(doc.title, String);
if (doc.owner && doc.owner != userId)
throw new Meteor.Error('No permission', 'Can\'t create a thread in the name of other');
doc.owner = userId;
doc.createdAt = new Date();
doc.updatedAt = new Date();
doc.deletedAt = null;
return true;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment