async function isAuthorizedComment(reqresnext) {
    if (req.isAuthenticated()) {
      try {
        let foundComment = await Comment.findById(req.params.comment_id);
        if (foundComment.author.id.equals(req.user._id)) {
            return next();
        } else {
            console.log("User is logged in but not matching");
            res.redirect('back');
        }
      } catch(error) {
          console.log("Error on find comment");
          console.log(error);
          res.redirect('back');
      }
    } else {
        console.log("user didn't logged in");
        res.redirect('back');
    }
}



아래 댓글 조언 반용해서 짯는데...


후.......