|
|
@@ -507,15 +507,17 @@ module.exports = function(crowi) {
|
|
|
if (!checkResult) {
|
|
|
return reject(new Error('Page is not granted for the user')); //PAGE_GRANT_ERROR, null);
|
|
|
} else {
|
|
|
- return resolve(pageData);
|
|
|
+ // return resolve(pageData);
|
|
|
+ self.populatePageData(pageData, revisionId || null).then(resolve).catch(reject);
|
|
|
}
|
|
|
})
|
|
|
.catch(function (err) {
|
|
|
return reject(err);
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- self.populatePageData(pageData, revisionId || null).then(resolve).catch(reject);
|
|
|
+ else {
|
|
|
+ self.populatePageData(pageData, revisionId || null).then(resolve).catch(reject);
|
|
|
+ }
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
@@ -785,6 +787,7 @@ module.exports = function(crowi) {
|
|
|
var PageGroupRelation = crowi.model('PageGroupRelation');
|
|
|
var UserGroupRelation = crowi.model('UserGroupRelation');
|
|
|
var provGrant = page.grant;
|
|
|
+ var grantUserGroup = null;
|
|
|
|
|
|
if (grant == GRANT_USER_GROUP && grantUserGroupId == null) {
|
|
|
grant = GRANT_PUBLIC;
|
|
|
@@ -809,15 +812,18 @@ module.exports = function(crowi) {
|
|
|
debug('grant is usergroup', grantUserGroupId);
|
|
|
UserGroupRelation.findByGroupIdAndUser(grantUserGroupId, userData)
|
|
|
.then(function(relation) {
|
|
|
+ debug('userGroupRelation is found : ', relation)
|
|
|
if (relation != null) {
|
|
|
- return PageGroupRelation.checkIsExistsRelationForPageAndGroup(page, relation.relatedGroup);
|
|
|
+ grantUserGroup = relation.relatedGroup;
|
|
|
+ return PageGroupRelation.checkIsExistsRelationForPageAndGroup(page, grantUserGroup);
|
|
|
}
|
|
|
else { return reject(new Error('No UserGroup is exists. userGroupId : ', grantUserGroupId)); }
|
|
|
})
|
|
|
.then(function(isAlreadyExists) {
|
|
|
+ debug('pageGroupRelation is exists ', isAlreadyExists);
|
|
|
if (!isAlreadyExists) {
|
|
|
- debug('create new Page and Group relations', relation.relatedGroup);
|
|
|
- PageGroupRelation.createRelation(relation.relatedGroup, page, function (err, relationData) {
|
|
|
+ debug('create new Page and Group relations', grantUserGroup);
|
|
|
+ PageGroupRelation.createRelation(grantUserGroup, page, function (err, relationData) {
|
|
|
if (err) {
|
|
|
return reject(err);
|
|
|
}
|
|
|
@@ -1235,9 +1241,12 @@ module.exports = function(crowi) {
|
|
|
var PageGroupRelation = crowi.model('PageGroupRelation');
|
|
|
var UserGroupRelation = crowi.model('UserGroupRelation');
|
|
|
|
|
|
+ debug('isExistsGrantedGroupFor is called.');
|
|
|
+
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
PageGroupRelation.findByPage(pageData)
|
|
|
.then(function (pageRelation) {
|
|
|
+ debug('PageGroupRelation.findByPage result is ', pageRelation);
|
|
|
if (pageRelation == null) {
|
|
|
debug('isExistsGrantedGroupFor is return resolve(false);');
|
|
|
return resolve(false);
|