Explorar o código

raise an error if the page does not exist

Shun Miyazawa %!s(int64=4) %!d(string=hai) anos
pai
achega
630719a8d6
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  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;