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

BugFix: Couldn't show root page if restricted in GROWI layout

Yuki Takei 7 лет назад
Родитель
Сommit
e62526ba5e

+ 1 - 0
CHANGES.md

@@ -6,6 +6,7 @@ CHANGES
 * Fix: Typeahead shows autocomplete wrongly
 * Fix: Move/Duplicate don't work
     * Introduced by 3.3.7
+* Fix: Couldn't show root page if restricted
 * Support: Upgrade libs
     * react
     * react-bootstrap-typeahead

+ 5 - 4
src/server/routes/page.js

@@ -190,12 +190,13 @@ module.exports = function(crowi, app) {
     // check whether this page has portal page
     const portalPageStatus = await getPortalPageState(path, req.user);
 
+    let view = 'customlayout-selector/page_list';
     const renderVars = { path };
 
     if (portalPageStatus === PORTAL_STATUS_FORBIDDEN) {
       // inject to req
       req.isForbidden = true;
-      return next();
+      view = 'customlayout-selector/forbidden';
     }
     else if (portalPageStatus === PORTAL_STATUS_EXISTS) {
       let portalPage = await Page.findByPathAndViewer(path, req.user);
@@ -214,7 +215,7 @@ module.exports = function(crowi, app) {
     await addRenderVarsForDescendants(renderVars, path, req.user, offset, limit);
 
     await interceptorManager.process('beforeRenderPage', req, res, renderVars);
-    return res.render('customlayout-selector/page_list', renderVars);
+    return res.render(view, renderVars);
   }
 
   async function showPageForGrowiBehavior(req, res, next) {
@@ -621,8 +622,8 @@ module.exports = function(crowi, app) {
       options.grantUserGroupId = grantUserGroupId;
     }
 
-      const Revision = crowi.model('Revision');
-      const previousRevision = await Revision.findById(revisionId);
+    const Revision = crowi.model('Revision');
+    const previousRevision = await Revision.findById(revisionId);
     try {
       page = await Page.updatePage(page, pageBody, previousRevision.body, req.user, options);
     }

+ 1 - 1
src/server/views/layout-growi/forbidden.html

@@ -2,7 +2,7 @@
 
 
 {% block content_header %}
-  {% include 'widget/header.html' %}
+  {% include 'widget/header.html' with {forbidden: true} %}
 {% endblock %}
 
 

+ 1 - 1
src/server/views/layout-growi/widget/header.html

@@ -39,7 +39,7 @@
       </ul>
       {% endif %}
 
-      {% if not page and ('/' === path or 'crowi' === behaviorType()) and not isUserPageList(path) and !isTrashPage() %}
+      {% if not page and not forbidden and ('/' === path or 'crowi' === behaviorType()) and not isUserPageList(path) and !isTrashPage() %}
         {% if '/' === path.slice(-1) %}
           {% include '../../widget/create_portal.html' %}
         {% endif %}