Просмотр исходного кода

delete change in obsolete-page.js

yuken 3 лет назад
Родитель
Сommit
ea1588c303

+ 1 - 1
packages/app/src/server/models/obsolete-page.js

@@ -375,7 +375,7 @@ export const getPageSchema = (crowi) => {
 
     const builder = new this.PageQueryBuilder(this.findOne({ path }), includeEmpty);
 
-    return builder.query;
+    return builder.query.exec();
   };
 
   /**

+ 12 - 4
packages/app/src/server/routes/apiv3/page.js

@@ -446,8 +446,6 @@ module.exports = (crowi) => {
     }
 
     const currentPageUserGroup = await UserGroup.findOne({ _id: grantedGroup });
-    const parentPageUserGroup = await UserGroup.findOne({ _id: parentPage.grantedGroup });
-
     const currentPageGrant = {
       grant,
       grantedGroup: currentPageUserGroup != null
@@ -458,6 +456,16 @@ module.exports = (crowi) => {
         : null,
     };
 
+    if (parentPage == null) {
+      const grantData = {
+        isForbidden: false,
+        currentPageGrant,
+        parentPageGrant: null,
+      };
+      return res.apiv3({ isGrantNormalized, grantData });
+    }
+
+    const parentPageUserGroup = await UserGroup.findOne({ _id: parentPage.grantedGroup });
     const parentPageGrant = {
       grant: parentPage.grant,
       grantedGroup: parentPageUserGroup != null
@@ -469,9 +477,9 @@ module.exports = (crowi) => {
     };
 
     const grantData = {
-      isForbidden: parentPage != null,
+      isForbidden: true,
       currentPageGrant,
-      parentPageGrant: parentPage != null ? parentPageGrant : null,
+      parentPageGrant,
     };
 
     return res.apiv3({ isGrantNormalized, grantData });