소스 검색

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

Yuki Takei 8 년 전
부모
커밋
6981377fbd
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()) {