Skip to content

Commit

Permalink
fix: check update page access using original page path
Browse files Browse the repository at this point in the history
  • Loading branch information
NGPixel committed Feb 20, 2022
1 parent 3f5388d commit 411802e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions server/models/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ module.exports = class Page extends Model {

// -> Check for page access
if (!WIKI.auth.checkAccess(opts.user, ['write:pages'], {
locale: opts.locale,
path: opts.path
locale: ogPage.localeCode,
path: ogPage.path
})) {
throw new WIKI.Error.PageUpdateForbidden()
}
Expand Down Expand Up @@ -456,6 +456,14 @@ module.exports = class Page extends Model {

// -> Perform move?
if ((opts.locale && opts.locale !== page.localeCode) || (opts.path && opts.path !== page.path)) {
// -> Check target path access
if (!WIKI.auth.checkAccess(opts.user, ['write:pages'], {
locale: opts.locale,
path: opts.path
})) {
throw new WIKI.Error.PageMoveForbidden()
}

await WIKI.models.pages.movePage({
id: page.id,
destinationLocale: opts.locale,
Expand Down

0 comments on commit 411802e

Please sign in to comment.