Explorar el Código

add formvalidator

zahmis hace 4 años
padre
commit
c040835327
Se han modificado 1 ficheros con 7 adiciones y 4 borrados
  1. 7 4
      src/server/routes/apiv3/slack-integration-settings.js

+ 7 - 4
src/server/routes/apiv3/slack-integration-settings.js

@@ -61,6 +61,10 @@ module.exports = (crowi) => {
       body('channel').trim().not().isEmpty()
         .isString(),
     ],
+    Credentials: [
+      body('slackSigningSecret').isString().not().isEmpty(),
+      body('slackBotToken').isString().not().isEmpty(),
+    ],
   };
 
   async function resetAllBotSettings() {
@@ -271,12 +275,13 @@ module.exports = (crowi) => {
    *           200:
    *             description: Succeeded to put CustomBotWithoutProxy setting.
    */
-  router.put('/without-proxy/update-settings', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
+  router.put('/without-proxy/update-settings', loginRequiredStrictly, adminRequired, csrf, apiV3FormValidator, async(req, res) => {
     const currentBotType = crowi.configManager.getConfig('crowi', 'slackbot:currentBotType');
     if (currentBotType !== 'customBotWithoutProxy') {
       const msg = 'Not CustomBotWithoutProxy';
       return res.apiv3Err(new ErrorV3(msg, 'not-customBotWithoutProxy'), 400);
     }
+
     const { slackSigningSecret, slackBotToken } = req.body;
     const requestParams = {
       'slackbot:signingSecret': slackSigningSecret,
@@ -297,8 +302,6 @@ module.exports = (crowi) => {
       logger.error('Error', error);
       return res.apiv3Err(new ErrorV3(msg, 'update-CustomBotSetting-failed'), 500);
     }
-
-
   });
 
 
@@ -315,7 +318,7 @@ module.exports = (crowi) => {
    *          200:
    *            description: Succeeded to update access tokens for slack
    */
-  router.put('/access-tokens', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
+  router.put('/access-tokens', loginRequiredStrictly, adminRequired, csrf, validator.Credentials, apiV3FormValidator, async(req, res) => {
     const SlackAppIntegration = mongoose.model('SlackAppIntegration');
     let checkTokens;
     let tokenGtoP;