itizawa 4 лет назад
Родитель
Сommit
82f0df6a3a
1 измененных файлов с 3 добавлено и 5 удалено
  1. 3 5
      src/server/routes/apiv3/slack-integration.js

+ 3 - 5
src/server/routes/apiv3/slack-integration.js

@@ -17,27 +17,25 @@ module.exports = (crowi) => {
   // Check if the access token is correct
   async function verifyAccessTokenFromProxy(req, res, next) {
     const tokenPtoG = req.headers['x-growi-ptog-tokens'];
+
     if (tokenPtoG == null) {
       const message = 'The value of header \'x-growi-ptog-tokens\' must not be empty.';
       logger.warn(message, { body: req.body });
       return res.status(400).send({ message });
     }
 
-    const slackAppIntegration = await SlackAppIntegration.findOne({ tokenPtoG });
+    const slackAppIntegrationCount = await SlackAppIntegration.estimatedDocumentCount({ tokenPtoG });
 
     logger.debug('verifyAccessTokenFromProxy', {
       tokenPtoG,
     });
 
-    if (slackAppIntegration == null) {
+    if (slackAppIntegrationCount === 0) {
       return res.status(403).send({
         message: 'The access token that identifies the request source is slackbot-proxy is invalid. Did you setup with `/growi register`?',
       });
     }
 
-    // set tokenGtoP for repsponse
-    req.body.tokenGtoP = slackAppIntegration.tokenGtoP;
-
     next();
   }