Procházet zdrojové kódy

fix #163 : Ensure that isCreator method returns false when userData is false

Yuki Takei před 8 roky
rodič
revize
6981377fbd
1 změnil soubory, kde provedl 5 přidání a 0 odebrání
  1. 5 0
      lib/models/page.js

+ 5 - 0
lib/models/page.js

@@ -94,6 +94,11 @@ module.exports = function(crowi) {
   };
   };
 
 
   pageSchema.methods.isCreator = function(userData) {
   pageSchema.methods.isCreator = function(userData) {
+    // ゲスト閲覧の場合は userData に false が入る
+    if (!userData) {
+      return false;
+    }
+
     if (this.populated('creator') && this.creator._id.toString() === userData._id.toString()) {
     if (this.populated('creator') && this.creator._id.toString() === userData._id.toString()) {
       return true;
       return true;
     } else if (this.creator.toString() === userData._id.toString()) {
     } else if (this.creator.toString() === userData._id.toString()) {