Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion client/themes/default/components/page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -559,11 +559,14 @@ export default {
tocDecoded () {
return JSON.parse(Buffer.from(this.toc, 'base64').toString())
},
currentUserId: get('user/id'),
tocPosition: get('site/tocPosition'),
hasAdminPermission: get('page/[email protected]'),
hasWritePagesPermission: get('page/[email protected]'),
hasManagePagesPermission: get('page/[email protected]'),
hasDeletePagesPermission: get('page/[email protected]'),
hasDeletePagesPermission() {
return get('page/[email protected]').call(this) || (this.authorId === this.currentUserId && this.hasWritePagesPermission)
},
hasReadSourcePermission: get('page/[email protected]'),
hasReadHistoryPermission: get('page/[email protected]'),
hasAnyPagePermissions () {
Expand Down
2 changes: 1 addition & 1 deletion server/graph/schemas/page.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ type PageMutation {

delete(
id: Int!
): DefaultResponse @auth(requires: ["delete:pages", "manage:system"])
): DefaultResponse @auth(requires: ["delete:pages", "write:pages", "manage:system"])

deleteTag(
id: Int!
Expand Down
11 changes: 9 additions & 2 deletions server/models/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,10 +795,17 @@ module.exports = class Page extends Model {
}

// -> Check for page access
if (!WIKI.auth.checkAccess(opts.user, ['delete:pages'], {
const isTheAuthorAndHasWritePermission = page.authorId === opts.user.id && WIKI.auth.checkAccess(opts.user, ['write:pages'], {
locale: page.locale,
path: page.path
})) {
})

const hasDeletePermission = WIKI.auth.checkAccess(opts.user, ['delete:pages'], {
locale: page.locale,
path: page.path
})

if (!isTheAuthorAndHasWritePermission && !hasDeletePermission) {
throw new WIKI.Error.PageDeleteForbidden()
}

Expand Down