Explorar o código

add validation pageId newPagePath

zahmis %!s(int64=5) %!d(string=hai) anos
pai
achega
1adb1edcba
Modificáronse 1 ficheiros con 7 adicións e 1 borrados
  1. 7 1
      src/server/routes/apiv3/pages.js

+ 7 - 1
src/server/routes/apiv3/pages.js

@@ -140,6 +140,12 @@ module.exports = (crowi) => {
       body('isRecursively').if(value => value != null).isBoolean().withMessage('isRecursively must be boolean'),
       body('socketClientId').if(value => value != null).isInt().withMessage('socketClientId must be int'),
     ],
+
+    duplicatePage: [
+      body('pageId').exists().withMessage('pageId is required'),
+      body('newPagePath').exists().withMessage('newPagePath is required'),
+
+    ],
   };
 
   async function createPageAction({
@@ -468,7 +474,7 @@ module.exports = (crowi) => {
    *          500:
    *            description: Internal server error.
    */
-  router.post('/duplicate', accessTokenParser, loginRequiredStrictly, csrf, async(req, res) => {
+  router.post('/duplicate', accessTokenParser, loginRequiredStrictly, csrf, validator.duplicatePage, async(req, res) => {
     const { pageId } = req.body;
 
     const newPagePath = pathUtils.normalizePath(req.body.pageNameInput);