Browse Source

modified the code so that when accessing /like-info unlogged, the error will not appear.

白石誠 5 years ago
parent
commit
429a1bfa0c
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/server/routes/apiv3/page.js

+ 1 - 1
src/server/routes/apiv3/page.js

@@ -202,7 +202,7 @@ module.exports = (crowi) => {
 
   router.get('/like-info', loginRequired, validator.likeInfo, async(req, res) => {
     const pageId = req.query._id;
-    const userId = req.user._id;
+    const userId = req.user ? req.user._id : null;
     try {
       const page = await Page.findById(pageId);
       const users = await Page.findById(pageId).populate('liker', User.USER_PUBLIC_FIELDS);