-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deny null #1020
deny null #1020
Changes from all commits
52a4c97
dd63545
a68e085
d53a6b1
3e5f610
8f17d34
cea6d9a
2fb44c7
cf34a2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -468,12 +468,12 @@ module.exports = function(crowi) { | |
}; | ||
|
||
pageSchema.methods.applyScope = function(user, grant, grantUserGroupId) { | ||
this.grant = grant; | ||
|
||
// reset | ||
this.grantedUsers = []; | ||
this.grantedGroup = null; | ||
|
||
this.grant = grant || GRANT_PUBLIC; | ||
|
||
if (grant !== GRANT_PUBLIC && grant !== GRANT_USER_GROUP) { | ||
this.grantedUsers.push(user._id); | ||
} | ||
|
@@ -934,7 +934,7 @@ module.exports = function(crowi) { | |
.cursor(); | ||
}; | ||
|
||
async function pushRevision(pageData, newRevision, user, grant, grantUserGroupId) { | ||
async function pushRevision(pageData, newRevision, user) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. これはただのゴミ掃除 |
||
await newRevision.save(); | ||
debug('Successfully saved new revision', newRevision); | ||
|
||
|
@@ -973,7 +973,7 @@ module.exports = function(crowi) { | |
// sanitize path | ||
path = crowi.xss.process(path); // eslint-disable-line no-param-reassign | ||
|
||
let grant = options.grant || GRANT_PUBLIC; | ||
let grant = options.grant; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Page.create に渡ってきたものはそのまま使う(portal の場合だけ public にする) |
||
// force public | ||
if (isPortalPath(path)) { | ||
grant = GRANT_PUBLIC; | ||
|
@@ -997,7 +997,7 @@ module.exports = function(crowi) { | |
|
||
let savedPage = await page.save(); | ||
const newRevision = Revision.prepareRevision(savedPage, body, null, user, { format }); | ||
const revision = await pushRevision(savedPage, newRevision, user, grant, grantUserGroupId); | ||
const revision = await pushRevision(savedPage, newRevision, user); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. これはただのゴミ掃除 |
||
savedPage = await this.findByPath(revision.path) | ||
.populate('revision') | ||
.populate('creator'); | ||
|
@@ -1012,8 +1012,8 @@ module.exports = function(crowi) { | |
validateCrowi(); | ||
|
||
const Revision = crowi.model('Revision'); | ||
const grant = options.grant || null; | ||
const grantUserGroupId = options.grantUserGroupId || null; | ||
const grant = options.grant || pageData.grant; // use the previous data if absence | ||
const grantUserGroupId = options.grantUserGroupId || pageData.grantUserGroupId; // use the previous data if absence | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update 時は指定がなければ元の値を使う |
||
const isSyncRevisionToHackmd = options.isSyncRevisionToHackmd; | ||
const socketClientId = options.socketClientId || null; | ||
|
||
|
@@ -1023,7 +1023,7 @@ module.exports = function(crowi) { | |
// update existing page | ||
let savedPage = await pageData.save(); | ||
const newRevision = await Revision.prepareRevision(pageData, body, previousBody, user); | ||
const revision = await pushRevision(savedPage, newRevision, user, grant, grantUserGroupId); | ||
const revision = await pushRevision(savedPage, newRevision, user); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. これはただのゴミ掃除 |
||
savedPage = await this.findByPath(revision.path) | ||
.populate('revision') | ||
.populate('creator'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -567,9 +567,12 @@ module.exports = function(crowi, app) { | |
return res.json(ApiResponse.error('Page exists', 'already_exists')); | ||
} | ||
|
||
const options = { | ||
grant, grantUserGroupId, overwriteScopesOfDescendants, socketClientId, pageTags, | ||
}; | ||
const options = { socketClientId }; | ||
if (grant != null) { | ||
options.grant = grant; | ||
options.grantUserGroupId = grantUserGroupId; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
const createdPage = await Page.create(pagePath, body, req.user, options); | ||
|
||
let savedTags; | ||
|
@@ -648,8 +651,6 @@ module.exports = function(crowi, app) { | |
const options = { isSyncRevisionToHackmd, socketClientId }; | ||
if (grant != null) { | ||
options.grant = grant; | ||
} | ||
if (grantUserGroupId != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. applyScope が賢くなったので、ここは grant が指定されているかどうかだけ見て grantUserGroupId も options に入れた。仮に |
||
options.grantUserGroupId = grantUserGroupId; | ||
} | ||
|
||
|
@@ -1116,6 +1117,8 @@ module.exports = function(crowi, app) { | |
req.body.path = newPagePath; | ||
req.body.body = page.revision.body; | ||
req.body.grant = page.grant; | ||
req.body.grantedUsers = page.grantedUsers; | ||
req.body.grantedGroup = page.grantedGroup; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. duplicate 時に元々バグがあった部分。コピー元データを使うように修正。 |
||
req.body.pageTags = originTags; | ||
|
||
return api.create(req, res); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null, undefined の場合に public にするのは最後の砦であるこのメソッドで行う