Parcourir la source

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

白石誠 il y a 5 ans
Parent
commit
429a1bfa0c
1 fichiers modifiés avec 1 ajouts et 1 suppressions
  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);