Skip to content
Snippets Groups Projects
Commit 3c6d5ae5 authored by Bogdan Cochior's avatar Bogdan Cochior
Browse files

Merge branch 'develop' of https://gitlab.coko.foundation/xpub/xpub-faraday into develop

parents 35dc350c 2676bb4c
No related branches found
No related tags found
1 merge request!6Agree/Decline to work on a manuscript
const config = require('config')
const Authsome = require('authsome')
const mode = require(config.get('authsome.mode'))
const authsome = new Authsome({ ...config.authsome, mode }, {})
module.exports = authsome
......@@ -40,6 +40,7 @@ module.exports = models => async (req, res) => {
error: notFoundError.message,
})
}
const baseUrl = `${req.protocol}://${req.get('host')}`
const params = {
baseUrl,
......
......@@ -19,7 +19,7 @@ module.exports = {
coll.visibleStatus = statuses[coll.status].private
}
},
filterRefusedReviewers: (coll, user) => {
filterRefusedInvitations: (coll, user) => {
const matchingInv = coll.invitations.find(inv => inv.userId === user.id)
if (matchingInv === undefined) return null
if (matchingInv.hasAnswer === true && !matchingInv.isAccepted) return null
......
......@@ -35,8 +35,12 @@ async function teamPermissions(user, operation, object, context) {
}
helpers.setPublicStatuses(coll, matchingCollPerm)
helpers.parseReviewerAuthors(coll, matchingCollPerm)
if (['reviewer'].includes(matchingCollPerm.permission)) {
return helpers.filterRefusedReviewers(coll, user)
if (
['reviewer', 'handlingEditor'].includes(
matchingCollPerm.permission,
)
) {
return helpers.filterRefusedInvitations(coll, user)
}
return coll
})
......@@ -97,11 +101,11 @@ function unauthenticatedUser(operation, object) {
async function authenticatedUser(user, operation, object, context) {
// Allow the authenticated user to POST a collection (but not with a 'filtered' property)
// if (operation === 'POST' && object.path === '/collections') {
// return {
// filter: collection => omit(collection, 'filtered'),
// }
// }
if (operation === 'POST' && object.path === '/collections') {
return {
filter: collection => omit(collection, 'filtered'),
}
}
// Allow the authenticated user to GET collections they own
if (operation === 'GET' && object === '/collections/') {
......
......@@ -21,9 +21,14 @@ const getDbConfig = () => {
module.exports = {
authsome: {
mode: path.resolve(__dirname, 'authsome.js'),
mode: path.resolve(__dirname, 'authsome-mode.js'),
teams: {
// TODO
handlingEditor: {
name: 'Handling Editors',
},
reviewer: {
name: 'Reviewer',
},
},
},
validations: path.resolve(__dirname, 'validations.js'),
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment