Explorar o código

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

白石誠 %!s(int64=5) %!d(string=hai) anos
pai
achega
429a1bfa0c
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  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);