forked from BenjaminRH/meteor-user-session
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
22 lines (20 loc) · 630 Bytes
/
Copy pathserver.js
File metadata and controls
22 lines (20 loc) · 630 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Publish only the current user's session variables to the client
Meteor.publish('userSessionCollection', function () {
return UserSessionCollection.find({ userId: this.userId });
});
// Check that the userId specified owns the documents
ownsDocument = function (userId, doc) {
return doc && doc.userId === userId;
}
// Allow methods for UserSessionCollection (security)
UserSessionCollection.allow({
insert: function (userId, doc) {
return ownsDocument(userId, doc);
},
update: function (userId, doc) {
return ownsDocument(userId, doc);
},
remove: function (userId, doc) {
return ownsDocument(userId, doc);
}
});