Ver Fonte

Fixed process

Taichi Masuyama há 4 anos atrás
pai
commit
e9e6bbfe20

+ 4 - 5
packages/app/src/server/routes/apiv3/pages.js

@@ -174,11 +174,10 @@ module.exports = (crowi) => {
     ],
     ],
     renamePage: [
     renamePage: [
       body('pageId').isMongoId().withMessage('pageId is required'),
       body('pageId').isMongoId().withMessage('pageId is required'),
-      body('revisionId').optional.isMongoId().withMessage('revisionId is required'), // required when v4
+      body('revisionId').optional().isMongoId().withMessage('revisionId is required'), // required when v4
       body('newPagePath').isLength({ min: 1 }).withMessage('newPagePath is required'),
       body('newPagePath').isLength({ min: 1 }).withMessage('newPagePath is required'),
       body('isRenameRedirect').if(value => value != null).isBoolean().withMessage('isRenameRedirect must be boolean'),
       body('isRenameRedirect').if(value => value != null).isBoolean().withMessage('isRenameRedirect must be boolean'),
       body('isRemainMetadata').if(value => value != null).isBoolean().withMessage('isRemainMetadata must be boolean'),
       body('isRemainMetadata').if(value => value != null).isBoolean().withMessage('isRemainMetadata must be boolean'),
-      body('isRecursively').if(value => value != null).isBoolean().withMessage('isRecursively must be boolean'),
     ],
     ],
 
 
     duplicatePage: [
     duplicatePage: [
@@ -456,8 +455,8 @@ module.exports = (crowi) => {
   router.put('/rename', /* accessTokenParser, loginRequiredStrictly, csrf, */validator.renamePage, apiV3FormValidator, async(req, res) => {
   router.put('/rename', /* accessTokenParser, loginRequiredStrictly, csrf, */validator.renamePage, apiV3FormValidator, async(req, res) => {
     const { pageId, isRecursively, revisionId } = req.body;
     const { pageId, isRecursively, revisionId } = req.body;
     // v4 compatible validation
     // v4 compatible validation
-    const isV5Compatible = this.crowi.configManager.getConfig('crowi', 'app:isV5Compatible');
-    if (!isV5Compatible || revisionId == null) {
+    const isV5Compatible = crowi.configManager.getConfig('crowi', 'app:isV5Compatible');
+    if (!isV5Compatible && revisionId == null) {
       return res.apiv3Err(new ErrorV3('revisionId must be a mongoId', 'invalid_body'), 400);
       return res.apiv3Err(new ErrorV3('revisionId must be a mongoId', 'invalid_body'), 400);
     }
     }
 
 
@@ -484,7 +483,7 @@ module.exports = (crowi) => {
     let page;
     let page;
 
 
     try {
     try {
-      page = await Page.findByIdAndViewer(pageId, req.user, null, true);
+      page = await Page.findByIdAndViewer(pageId, req.user, null, true) || await Page.findOne({ _id: pageId });
 
 
       if (page == null) {
       if (page == null) {
         return res.apiv3Err(new ErrorV3(`Page '${pageId}' is not found or forbidden`, 'notfound_or_forbidden'), 401);
         return res.apiv3Err(new ErrorV3(`Page '${pageId}' is not found or forbidden`, 'notfound_or_forbidden'), 401);

+ 1 - 1
packages/app/src/server/service/page.ts

@@ -217,7 +217,7 @@ class PageService {
       try {
       try {
         const shouldCheckDescendants = false;
         const shouldCheckDescendants = false;
 
 
-        isGrantNormalized = await this.crowi.pageGrantService.isGrantNormalized(path, grant, grantedUserIds, grantUserGroupId, shouldCheckDescendants);
+        isGrantNormalized = await this.crowi.pageGrantService.isGrantNormalized(newPagePath, grant, grantedUserIds, grantUserGroupId, shouldCheckDescendants);
       }
       }
       catch (err) {
       catch (err) {
         logger.error(`Failed to validate grant of page at "${newPagePath}" when renaming`, err);
         logger.error(`Failed to validate grant of page at "${newPagePath}" when renaming`, err);