Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
X
xpub-faraday
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
This is an archived project. Repository and other project resources are read-only.
"...git@gitlab.coko.foundation:wax/wax-prosemirror.git" did not exist on "d5cc1fe48a867317b54f501581930436d7f10fdf"
Show more breadcrumbs
xpub
xpub-faraday
Commits
6d408a99
Commit
6d408a99
authored
6 years ago
by
Alexandru Munteanu
Browse files
Options
Downloads
Patches
Plain Diff
latest changes
parent
64d39c14
No related branches found
No related tags found
2 merge requests
!13
Sprint #14
,
!11
Submit revision
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/xpub-faraday/config/authsome-helpers.js
+4
-0
4 additions, 0 deletions
packages/xpub-faraday/config/authsome-helpers.js
packages/xpub-faraday/config/authsome-mode.js
+98
-10
98 additions, 10 deletions
packages/xpub-faraday/config/authsome-mode.js
with
102 additions
and
10 deletions
packages/xpub-faraday/config/authsome-helpers.js
+
4
−
0
View file @
6d408a99
...
@@ -80,6 +80,9 @@ const heIsInvitedToFragment = async ({ user, Team, collectionId }) =>
...
@@ -80,6 +80,9 @@ const heIsInvitedToFragment = async ({ user, Team, collectionId }) =>
t
=>
t
.
members
.
includes
(
user
.
id
)
&&
t
.
object
.
id
===
collectionId
,
t
=>
t
.
members
.
includes
(
user
.
id
)
&&
t
.
object
.
id
===
collectionId
,
)
)
const
getUserPermissions
=
async
({
user
,
Team
,
mapFn
=
x
=>
x
})
=>
(
await
Promise
.
all
(
user
.
teams
.
map
(
teamId
=>
Team
.
find
(
teamId
)))).
map
(
mapFn
)
module
.
exports
=
{
module
.
exports
=
{
filterObjectData
,
filterObjectData
,
parseAuthorsData
,
parseAuthorsData
,
...
@@ -87,5 +90,6 @@ module.exports = {
...
@@ -87,5 +90,6 @@ module.exports = {
getTeamsByPermissions
,
getTeamsByPermissions
,
filterRefusedInvitations
,
filterRefusedInvitations
,
//
//
getUserPermissions
,
heIsInvitedToFragment
,
heIsInvitedToFragment
,
}
}
This diff is collapsed.
Click to expand it.
packages/xpub-faraday/config/authsome-mode.js
+
98
−
10
View file @
6d408a99
const
get
=
require
(
'
lodash
/get
'
)
const
{
get
,
pickBy
,
omit
}
=
require
(
'
lodash
'
)
const
pickBy
=
require
(
'
lodash/pickBy
'
)
const
config
=
require
(
'
config
'
)
const
omit
=
require
(
'
lodash/omit
'
)
const
helpers
=
require
(
'
./authsome-helpers
'
)
const
helpers
=
require
(
'
./authsome-helpers
'
)
const
statuses
=
config
.
get
(
'
statuses
'
)
async
function
teamPermissions
(
user
,
operation
,
object
,
context
)
{
async
function
teamPermissions
(
user
,
operation
,
object
,
context
)
{
const
{
models
}
=
context
const
{
models
}
=
context
const
permissions
=
[
'
handlingEditor
'
,
'
author
'
,
'
reviewer
'
]
const
permissions
=
[
'
handlingEditor
'
,
'
author
'
,
'
reviewer
'
]
...
@@ -111,6 +113,8 @@ function unauthenticatedUser(operation, object) {
...
@@ -111,6 +113,8 @@ function unauthenticatedUser(operation, object) {
return
false
return
false
}
}
const
publicStatusesPermissions
=
[
'
author
'
,
'
reviewer
'
]
async
function
authenticatedUser
(
user
,
operation
,
object
,
context
)
{
async
function
authenticatedUser
(
user
,
operation
,
object
,
context
)
{
// Allow the authenticated user to POST a collection (but not with a 'filtered' property)
// Allow the authenticated user to POST a collection (but not with a 'filtered' property)
if
(
operation
===
'
POST
'
&&
object
.
path
===
'
/collections
'
)
{
if
(
operation
===
'
POST
'
&&
object
.
path
===
'
/collections
'
)
{
...
@@ -119,13 +123,97 @@ async function authenticatedUser(user, operation, object, context) {
...
@@ -119,13 +123,97 @@ async function authenticatedUser(user, operation, object, context) {
}
}
}
}
// get fragments for invited reviewers
if
(
operation
===
'
GET
'
)
{
if
(
if
(
get
(
object
,
'
path
'
)
===
'
/collections
'
)
{
operation
===
'
GET
'
&&
return
{
get
(
object
,
'
type
'
)
===
'
fragment
'
&&
filter
:
async
collections
=>
{
get
(
object
,
'
invitations
'
).
some
(
i
=>
i
.
userId
===
user
.
id
)
const
userPermissions
=
await
helpers
.
getUserPermissions
({
)
{
user
,
return
true
Team
:
context
.
models
.
Team
,
mapFn
:
t
=>
({
objectId
:
t
.
object
.
id
,
objectType
:
t
.
object
.
type
,
permissions
:
t
.
teamType
.
permissions
,
}),
})
return
collections
.
filter
(
collection
=>
{
if
(
collection
.
owners
.
includes
(
user
.
id
))
{
return
true
}
const
collectionPermission
=
userPermissions
.
find
(
p
=>
p
.
objectId
===
collection
.
id
,
)
if
(
collectionPermission
)
{
return
true
}
const
fragmentPermission
=
userPermissions
.
find
(
p
=>
collection
.
fragments
.
includes
(
p
.
objectId
),
)
if
(
fragmentPermission
)
{
return
true
}
return
false
})
},
}
}
if
(
get
(
object
,
'
type
'
)
===
'
collection
'
)
{
return
{
filter
:
async
collection
=>
{
const
status
=
get
(
collection
,
'
status
'
)
||
'
draft
'
const
userPermissions
=
await
helpers
.
getUserPermissions
({
user
,
Team
:
context
.
models
.
Team
,
mapFn
:
t
=>
({
objectId
:
t
.
object
.
id
,
objectType
:
t
.
object
.
type
,
permissions
:
t
.
teamType
.
permissions
,
}),
})
if
(
collection
.
owners
.
map
(
o
=>
o
.
id
).
includes
(
user
.
id
))
{
return
collection
}
const
collectionPermission
=
userPermissions
.
find
(
p
=>
p
.
objectId
===
collection
.
id
,
)
if
(
publicStatusesPermissions
.
includes
(
get
(
collectionPermission
)))
{
collection
.
visibleStatus
=
statuses
[
status
].
public
}
return
collection
},
}
}
if
(
get
(
object
,
'
type
'
)
===
'
fragment
'
)
{
const
userPermissions
=
await
helpers
.
getUserPermissions
({
user
,
Team
:
context
.
models
.
Team
,
mapFn
:
t
=>
({
objectId
:
t
.
object
.
id
,
objectType
:
t
.
object
.
type
,
permissions
:
t
.
teamType
.
permissions
,
}),
})
const
permission
=
userPermissions
.
find
(
p
=>
p
.
objectId
===
object
.
id
||
p
.
objectId
===
object
.
collectionId
,
)
if
(
!
permission
)
return
false
return
{
filter
:
fragment
=>
{
if
(
permission
.
permissions
===
'
reviewer
'
)
{
fragment
.
files
=
omit
(
fragment
.
files
,
[
'
coverLetter
'
])
fragment
.
authors
=
fragment
.
authors
.
map
(
a
=>
omit
(
a
,
[
'
email
'
]))
}
return
fragment
},
}
}
}
}
// TODO: in the future give him the non draft version of the fragment
// TODO: in the future give him the non draft version of the fragment
...
...
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