Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Kotahi
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
"...components/git@gitlab.coko.foundation:yannis/editoria.git" did not exist on "f25d900b38f06ffb9ce2fa05d11be87f9fac744b"
Show more breadcrumbs
Omo Oaiya
Kotahi
Commits
dbf3ccfc
Commit
dbf3ccfc
authored
4 years ago
by
Jure
Browse files
Options
Downloads
Patches
Plain Diff
fix: add file access to permissions
parent
0623dc98
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
config/permissions.js
+44
-4
44 additions, 4 deletions
config/permissions.js
with
44 additions
and
4 deletions
config/permissions.js
+
44
−
4
View file @
dbf3ccfc
...
...
@@ -44,7 +44,7 @@ const userIsAdmin = rule({ cache: 'contextual' })(
async
(
parent
,
args
,
ctx
,
info
)
=>
ctx
.
user
&&
ctx
.
user
.
admin
,
)
const
parent
M
anuscript
IsP
ublished
=
rule
({
cache
:
'
contextual
'
})(
const
parent
_m
anuscript
_is_p
ublished
=
rule
({
cache
:
'
contextual
'
})(
async
(
parent
,
args
,
ctx
,
info
)
=>
{
const
manuscript
=
await
ctx
.
models
.
Manuscript
.
query
().
findById
(
parent
.
manuscriptId
,
...
...
@@ -53,7 +53,7 @@ const parentManuscriptIsPublished = rule({ cache: 'contextual' })(
},
)
const
review
IsByC
urrent
U
ser
=
rule
({
cache
:
'
contextual
'
})(
const
review
_is_by_c
urrent
_u
ser
=
rule
({
cache
:
'
contextual
'
})(
async
(
parent
,
args
,
ctx
,
info
)
=>
{
const
rows
=
ctx
.
user
&&
...
...
@@ -156,6 +156,37 @@ const user_is_author = rule({ cache: 'strict' })(
},
)
// ¯\_(ツ)_/¯
const
current_user_is_the_reviewer_of_the_manuscript_of_the_file_and_review_not_complete
=
rule
(
{
cache
:
'
strict
'
,
},
)(
async
(
parent
,
args
,
ctx
,
info
)
=>
{
const
manuscript
=
await
ctx
.
models
.
File
.
relatedQuery
(
'
manuscript
'
)
.
for
(
parent
.
id
)
.
first
()
const
team
=
await
ctx
.
models
.
Team
.
query
()
.
where
({
manuscriptId
:
manuscript
.
id
,
role
:
'
reviewer
'
,
})
.
first
()
if
(
!
team
)
{
return
false
}
const
members
=
await
team
.
$relatedQuery
(
'
members
'
)
.
where
(
'
userId
'
,
ctx
.
user
.
id
)
if
(
members
&&
members
[
0
]
&&
members
[
0
].
status
!==
'
completed
'
)
{
return
true
}
return
false
})
const
permissions
=
shield
(
{
Query
:
{
...
...
@@ -166,7 +197,7 @@ const permissions = shield(
manuscripts
:
allow
,
manuscript
:
allow
,
messages
:
allow
,
getFile
:
allow
,
getFile
:
allow
,
// this is a query that gets the form
},
Mutation
:
{
createManuscript
:
isAuthenticated
,
...
...
@@ -174,6 +205,7 @@ const permissions = shield(
createMessage
:
userIsAllowedToChat
,
updateReview
:
user_is_review_author_and_review_is_not_completed
,
reviewerResponse
:
user_is_invited_reviewer
,
completeReview
:
user_is_review_author_and_review_is_not_completed
,
},
Subscription
:
{
messageCreated
:
userIsAllowedToChat
,
...
...
@@ -185,7 +217,15 @@ const permissions = shield(
User
:
allow
,
PaginatedManuscripts
:
allow
,
Manuscript
:
allow
,
Review
:
or
(
parentManuscriptIsPublished
,
reviewIsByCurrentUser
),
File
:
or
(
parent_manuscript_is_published
,
or
(
current_user_is_the_reviewer_of_the_manuscript_of_the_file_and_review_not_complete
,
userIsEditor
,
userIsAdmin
,
),
),
Review
:
or
(
parent_manuscript_is_published
,
review_is_by_current_user
),
ReviewComment
:
allow
,
Channel
:
allow
,
Message
:
allow
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment