Ver Fonte

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

Yuki Takei há 8 anos atrás
pai
commit
6981377fbd
1 ficheiros alterados com 5 adições e 0 exclusões
  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) {
+    // ゲスト閲覧の場合は userData に false が入る
+    if (!userData) {
+      return false;
+    }
+
     if (this.populated('creator') && this.creator._id.toString() === userData._id.toString()) {
       return true;
     } else if (this.creator.toString() === userData._id.toString()) {