Преглед изворни кода

BugFix: correspond to the situation that attachment is not found

Yuki Takei пре 7 година
родитељ
комит
d5e2f03d69
1 измењених фајлова са 4 додато и 0 уклоњено
  1. 4 0
      src/server/routes/attachment.js

+ 4 - 0
src/server/routes/attachment.js

@@ -35,6 +35,10 @@ module.exports = function(crowi, app) {
    * @param {boolean} forceDownload
    */
   async function responseForAttachment(res, user, attachment, forceDownload) {
+    if (attachment == null) {
+      return res.json(ApiResponse.error('attachment not found'));
+    }
+
     const isAccessible = await isAccessibleByViewer(user, attachment);
     if (!isAccessible) {
       return res.json(ApiResponse.error(`Forbidden to access to the attachment '${attachment.id}'`));