|
|
@@ -1,3 +1,16 @@
|
|
|
+/**
|
|
|
+ * The Exception class thrown when the user has no grant to see the page
|
|
|
+ *
|
|
|
+ * @class UserHasNoGrantException
|
|
|
+ */
|
|
|
+class UserHasNoGrantException {
|
|
|
+ constructor(message, user) {
|
|
|
+ this.name = this.constructor.name;
|
|
|
+ this.message = message;
|
|
|
+ this.user = user;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
module.exports = function(crowi) {
|
|
|
var debug = require('debug')('growi:models:page')
|
|
|
, mongoose = require('mongoose')
|
|
|
@@ -511,13 +524,13 @@ module.exports = function(crowi) {
|
|
|
if (!pageData.isGrantedFor(userData)) {
|
|
|
PageGroupRelation.isExistsGrantedGroupForPageAndUser(pageData, userData)
|
|
|
.then(isExists => {
|
|
|
- if (!isExists) {
|
|
|
- return reject(new Error('Page is not granted for the user')); //PAGE_GRANT_ERROR, null);
|
|
|
- }
|
|
|
- else {
|
|
|
+ if (isExists) {
|
|
|
// return resolve(pageData);
|
|
|
self.populatePageData(pageData, revisionId || null).then(resolve).catch(reject);
|
|
|
}
|
|
|
+ else {
|
|
|
+ return reject(new UserHasNoGrantException('Page is not granted for the user', userData));
|
|
|
+ }
|
|
|
})
|
|
|
.catch(function(err) {
|
|
|
return reject(err);
|