Browse Source

fix validation

zahmis 5 years ago
parent
commit
2188e9c0c7
1 changed files with 4 additions and 6 deletions
  1. 4 6
      src/server/routes/apiv3/slack-bot-setting.js

+ 4 - 6
src/server/routes/apiv3/slack-bot-setting.js

@@ -23,8 +23,8 @@ module.exports = (crowi) => {
 
   const validator = {
     CusotmBotSettings: [
-      body('slackSigningSecret').if(value => value != null).isStirng(),
-      body('slackBotToken').if(value => value != null).isStirng(),
+      body('slackSigningSecret').exists().not().isEmpty({ ignore_whitespace: true }),
+      body('slackBotToken').exists().not().isEmpty({ ignore_whitespace: true }),
     ],
   };
 
@@ -58,11 +58,9 @@ module.exports = (crowi) => {
 
   router.put('/custom-bot-setting',
     accessTokenParser, loginRequiredStrictly, adminRequired, csrf, validator.CusotmBotSettings, apiV3FormValidator, async(req, res) => {
-
       const requestParams = {
-      // temp data
-        'slackbot:signingSecret': 1234567890, // req.body.slackSigningSecret
-        'slackbot:token': 'asdfghjkkl1234567890', // req.body.slackBotToken
+        'slackbot:signingSecret': req.body.slackSigningSecret,
+        'slackbot:token': req.body.slackBotToken,
       };
 
       try {