Reputation: 63619
When doing checks with the audit-argument-checks
package, how should you do the matching when checking a Meteor.userId()
? Does the userId needs to be really checked?
Meteor.publish('scores', function(userId) {
check(userId, Match.any)
return Scores.find({userId: userId})
})
Upvotes: 1
Views: 533
Reputation: 4138
If the user is logged in, the publish function will already have the userId. It is accessible with this.userId
so no need for the user to pass it or to check it.
Like this:
Meteor.publish('scores', function() {
return Scores.find({userId: this.userId})
});
Upvotes: 3
Reputation: 7680
Since ID generation for the built in users collection is always 'STRING'
and cannot be altered, you can do:
check(userId, String);
If you are using 'MONGO'
ID generation for other collections, you'll want to do:
check(docId, Meteor.Collection.ObjectID);
Upvotes: 4