I have simple code here.
The intention of it is to verify the user with the user who wrote the post and allow the verified user to edit the post.
exports.edit = function(req, res){
    Post.findById(req.params.post_id, function(err, post){
        if(err){
            return res.json({
                type:false,
                message:"error!"
            });
        }else if(!post){
            return res.json({
                type:false,
                message:"no post with the id"
            })
        }else{
            console.log(req.user._id, typeof req.user._id);
            console.log(post.author.user_id, typeof post.author.user_id);
            if(req.user._id === post.author.user_id){ // doesn't work!!
                return res.json({
                    type:false,
                    message:"notAuthorized"
                }); 
            }else{
                return res.json({
                    type:true,
                    message:"it works",
                    data:post
                }); 
            }
        }
    });
}
The console says:
557c6922925a81930d2ce 'object'
557c6922925a81930d2ce 'object'
Which means they are equal in value and also equal in types.
I tried with == too, but that also doesn't work.
I am suspecting there needs to be something done to compare objects, but I don't know exactly what I should do.
 
     
     
     
     
     
     
     
     
    