Przeglądaj źródła

raise an error if the page does not exist

Shun Miyazawa 4 lat temu
rodzic
commit
630719a8d6
1 zmienionych plików z 4 dodań i 0 usunięć
  1. 4 0
      packages/app/src/server/routes/apiv3/page.js

+ 4 - 0
packages/app/src/server/routes/apiv3/page.js

@@ -540,6 +540,10 @@ module.exports = (crowi) => {
   router.get('/subscribe', loginRequiredStrictly, validator.subscribeStatus, apiV3FormValidator, async(req, res) => {
     const { pageId } = req.query;
     const userId = req.user._id;
+
+    const page = await Page.findById(pageId);
+    if (!page) throw new Error('Page not found');
+
     try {
       const subscription = await Subscription.findByUserIdAndTargetId(userId, pageId);
       const subscribing = subscription ? subscription.isSubscribing() : null;