Shun Miyazawa 3 лет назад
Родитель
Сommit
59ba5c0523

+ 1 - 8
packages/app/src/server/middlewares/certify-brand-logo.ts

@@ -1,14 +1,7 @@
 export const generateCertifyBrandLogoMiddleware = (crowi) => {
 
   return async(req, res, next) => {
-
-    const { attachmentService } = crowi;
-    const isBrandLogoExist = await attachmentService.isBrandLogoExist();
-
-    if (isBrandLogoExist) {
-      req.isBrandLogo = true;
-    }
-
+    req.isBrandLogo = true;
     next();
   };
 

+ 6 - 2
packages/app/src/server/routes/attachment.js

@@ -297,9 +297,13 @@ module.exports = function(crowi, app) {
   };
 
   api.getBrandLogo = async function(req, res) {
-    const attachment = await Attachment.findOne({ attachmentType: AttachmentType.BRAND_LOGO });
+    const brandLogoAttachment = await Attachment.findOne({ attachmentType: AttachmentType.BRAND_LOGO });
 
-    return responseForAttachment(req, res, attachment);
+    if (brandLogoAttachment == null) {
+      return res.status(404).json(ApiResponse.error('Brand logo does not exist'));
+    }
+
+    return responseForAttachment(req, res, brandLogoAttachment);
   };
 
   /**