|
@@ -786,9 +786,6 @@ module.exports = function(crowi) {
|
|
|
|
|
|
|
|
pageSchema.statics.updateGrant = function (page, grant, userData, grantUserGroupId) {
|
|
pageSchema.statics.updateGrant = function (page, grant, userData, grantUserGroupId) {
|
|
|
var Page = this;
|
|
var Page = this;
|
|
|
- var PageGroupRelation = crowi.model('PageGroupRelation');
|
|
|
|
|
- var UserGroupRelation = crowi.model('UserGroupRelation');
|
|
|
|
|
- var provGrant = page.grant;
|
|
|
|
|
|
|
|
|
|
if (grant == GRANT_USER_GROUP && grantUserGroupId == null) {
|
|
if (grant == GRANT_USER_GROUP && grantUserGroupId == null) {
|
|
|
throw new Error('grant userGroupId is not specified');
|
|
throw new Error('grant userGroupId is not specified');
|
|
@@ -817,24 +814,25 @@ module.exports = function(crowi) {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
pageSchema.statics.updateGrantUserGroup = function (page, grant, grantUserGroupId, userData) {
|
|
pageSchema.statics.updateGrantUserGroup = function (page, grant, grantUserGroupId, userData) {
|
|
|
|
|
+ var UserGroupRelation = crowi.model('UserGroupRelation');
|
|
|
|
|
+ var PageGroupRelation = crowi.model('PageGroupRelation');
|
|
|
|
|
|
|
|
// グループの場合
|
|
// グループの場合
|
|
|
if (grant == GRANT_USER_GROUP) {
|
|
if (grant == GRANT_USER_GROUP) {
|
|
|
debug('grant is usergroup', grantUserGroupId);
|
|
debug('grant is usergroup', grantUserGroupId);
|
|
|
- UserGroupRelation.findByGroupIdAndUser(grantUserGroupId, userData)
|
|
|
|
|
|
|
+ return UserGroupRelation.findByGroupIdAndUser(grantUserGroupId, userData)
|
|
|
.then((relation) => {
|
|
.then((relation) => {
|
|
|
if (relation == null) {
|
|
if (relation == null) {
|
|
|
- reject(new Error('no relations were exist for group and user.'));
|
|
|
|
|
|
|
+ return reject(new Error('no relations were exist for group and user.'));
|
|
|
}
|
|
}
|
|
|
return PageGroupRelation.findOrCreateRelationForPageAndGroup(page, relation.relatedGroup);
|
|
return PageGroupRelation.findOrCreateRelationForPageAndGroup(page, relation.relatedGroup);
|
|
|
-
|
|
|
|
|
})
|
|
})
|
|
|
.catch((err) => {
|
|
.catch((err) => {
|
|
|
return reject(new Error('No UserGroup is exists. userGroupId : ', grantUserGroupId));
|
|
return reject(new Error('No UserGroup is exists. userGroupId : ', grantUserGroupId));
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- PageGroupRelation.removeAllByPage(page);
|
|
|
|
|
|
|
+ return PageGroupRelation.removeAllByPage(page);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
};
|
|
};
|