Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
2cb30410
Unverified
Commit
2cb30410
authored
Nov 08, 2022
by
natsutteatsuiyone
Committed by
GitHub
Nov 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Page Rules based on Tag Matches do not work for comment permissions (#5819)
parent
1893fd49
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
comment.js
server/graph/resolvers/comment.js
+12
-3
comments.js
server/models/comments.js
+6
-3
No files found.
server/graph/resolvers/comment.js
View file @
2cb30410
...
...
@@ -40,9 +40,13 @@ module.exports = {
* Fetch list of comments for a page
*/
async
list
(
obj
,
args
,
context
)
{
const
page
=
await
WIKI
.
models
.
pages
.
query
().
select
(
'id'
).
findOne
({
localeCode
:
args
.
locale
,
path
:
args
.
path
})
const
page
=
await
WIKI
.
models
.
pages
.
query
().
select
(
'pages.id'
).
findOne
({
localeCode
:
args
.
locale
,
path
:
args
.
path
})
.
withGraphJoined
(
'tags'
)
.
modifyGraph
(
'tags'
,
builder
=>
{
builder
.
select
(
'tag'
)
})
if
(
page
)
{
if
(
WIKI
.
auth
.
checkAccess
(
context
.
req
.
user
,
[
'read:comments'
],
args
))
{
if
(
WIKI
.
auth
.
checkAccess
(
context
.
req
.
user
,
[
'read:comments'
],
{
tags
:
page
.
tags
,
...
args
}
))
{
const
comments
=
await
WIKI
.
models
.
comments
.
query
().
where
(
'pageId'
,
page
.
id
).
orderBy
(
'createdAt'
)
return
comments
.
map
(
c
=>
({
...
c
,
...
...
@@ -66,10 +70,15 @@ module.exports = {
throw
new
WIKI
.
Error
.
CommentNotFound
()
}
const
page
=
await
WIKI
.
models
.
pages
.
query
().
select
(
'localeCode'
,
'path'
).
findById
(
cm
.
pageId
)
.
withGraphJoined
(
'tags'
)
.
modifyGraph
(
'tags'
,
builder
=>
{
builder
.
select
(
'tag'
)
})
if
(
page
)
{
if
(
WIKI
.
auth
.
checkAccess
(
context
.
req
.
user
,
[
'read:comments'
],
{
path
:
page
.
path
,
locale
:
page
.
localeCode
locale
:
page
.
localeCode
,
tags
:
page
.
tags
}))
{
return
{
...
cm
,
...
...
server/models/comments.js
View file @
2cb30410
...
...
@@ -99,7 +99,8 @@ module.exports = class Comment extends Model {
if
(
page
)
{
if
(
!
WIKI
.
auth
.
checkAccess
(
user
,
[
'write:comments'
],
{
path
:
page
.
path
,
locale
:
page
.
localeCode
locale
:
page
.
localeCode
,
tags
:
page
.
tags
}))
{
throw
new
WIKI
.
Error
.
CommentPostForbidden
()
}
...
...
@@ -136,7 +137,8 @@ module.exports = class Comment extends Model {
if
(
page
)
{
if
(
!
WIKI
.
auth
.
checkAccess
(
user
,
[
'manage:comments'
],
{
path
:
page
.
path
,
locale
:
page
.
localeCode
locale
:
page
.
localeCode
,
tags
:
page
.
tags
}))
{
throw
new
WIKI
.
Error
.
CommentManageForbidden
()
}
...
...
@@ -169,7 +171,8 @@ module.exports = class Comment extends Model {
if
(
page
)
{
if
(
!
WIKI
.
auth
.
checkAccess
(
user
,
[
'manage:comments'
],
{
path
:
page
.
path
,
locale
:
page
.
localeCode
locale
:
page
.
localeCode
,
tags
:
page
.
tags
}))
{
throw
new
WIKI
.
Error
.
CommentManageForbidden
()
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment