Skip to content

Commit

Permalink
enhanced .findByIdForUser
Browse files Browse the repository at this point in the history
  • Loading branch information
abarnhard committed Aug 26, 2014
1 parent 86e3ec2 commit 88ac357
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions app/models/goal.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ Goal.findAllByUserId = function(id, cb){

Goal.findByIdForUser = function(goalId, userId, cb){
goalId = Mongo.ObjectID(goalId);
Goal.collection.findOne({_id:goalId}, function(err, goal){
if(goal.userId.toString() === userId.toString()){
cb(err, goal);
}else{
cb('ERROR:INVALID USER ID', null);
}
});
Goal.collection.findOne({_id:goalId, userId:userId}, cb);
};

module.exports = Goal;
Expand Down

0 comments on commit 88ac357

Please sign in to comment.