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

Merge pull request #2947 from weseek/fix/do-not-let-guest-user-edit-mode-in-top-page-content-edit-button

Fix/do not let guest user edit mode in top page content edit button
Sizma yosimaz 5 лет назад
Родитель
Сommit
bf28a2b205
2 измененных файлов с 9 добавлено и 5 удалено
  1. 0 5
      src/client/js/legacy/crowi.js
  2. 9 0
      src/client/js/services/NavigationContainer.js

+ 0 - 5
src/client/js/legacy/crowi.js

@@ -202,11 +202,6 @@ $(() => {
 window.addEventListener('load', (e) => {
   const { appContainer } = window;
 
-  // do nothing if user is guest
-  if (appContainer.currentUser == null) {
-    return;
-  }
-
   // hash on page
   if (window.location.hash) {
     const navigationContainer = appContainer.getContainer('NavigationContainer');

+ 9 - 0
src/client/js/services/NavigationContainer.js

@@ -1,4 +1,7 @@
 import { Container } from 'unstated';
+import loggerFactory from '@alias/logger';
+
+const logger = loggerFactory('growi:services:NavigationContainer');
 
 /**
  * Service container related to options for Application
@@ -86,6 +89,12 @@ export default class NavigationContainer extends Container {
   }
 
   setEditorMode(editorMode) {
+
+    if (this.appContainer.currentUser == null) {
+      logger.warn('Please login or signup to edit the page or use hackmd.');
+      return;
+    }
+
     this.setState({ editorMode });
     if (editorMode === 'view') {
       $('body').removeClass('on-edit');