Răsfoiți Sursa

throw new Error without token

itizawa 5 ani în urmă
părinte
comite
e169299340
1 a modificat fișierele cu 3 adăugiri și 7 ștergeri
  1. 3 7
      src/server/routes/apiv3/slack-bot.js

+ 3 - 7
src/server/routes/apiv3/slack-bot.js

@@ -1,6 +1,5 @@
 
 
 const express = require('express');
 const express = require('express');
-const mongoose = require('mongoose');
 
 
 const router = express.Router();
 const router = express.Router();
 
 
@@ -12,14 +11,11 @@ module.exports = (crowi) => {
   function accessTokenParserForSlackBot(req, res, next) {
   function accessTokenParserForSlackBot(req, res, next) {
     const slackBotAccessToken = req.body.slack_bot_access_token || null;
     const slackBotAccessToken = req.body.slack_bot_access_token || null;
     if (slackBotAccessToken == null) {
     if (slackBotAccessToken == null) {
-      return next();
+      throw new Error('slack_bot_access_token is required');
     }
     }
 
 
-    if (slackBotAccessToken === crowi.configManager.getConfig('crowi', 'slackbot:access-token')) {
-      req.body.user = {
-        id: new mongoose.Types.ObjectId(),
-        username: 'slackBot',
-      };
+    if (slackBotAccessToken !== crowi.configManager.getConfig('crowi', 'slackbot:access-token')) {
+      throw new Error('slack_bot_access_token is required');
     }
     }
     next();
     next();
   }
   }