Преглед изворни кода

Merge pull request #164 from weseek/fix/163-guest-user-accesses-to-private-pages

fix #163 : Ensure that isCreator method returns false when userData i…
Yuki Takei пре 8 година
родитељ
комит
bca3039530
1 измењених фајлова са 5 додато и 0 уклоњено
  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()) {