-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecureWithAllow.js
More file actions
21 lines (21 loc) · 811 Bytes
/
Copy pathsecureWithAllow.js
File metadata and controls
21 lines (21 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;
},
remove: function (userId, doc) {
if(!userId)
throw new Meteor.Error('Unauthorized', 'Please login before perform an action');
return result = doc.owner === userId;
},
});
}