Only show token-based projects if accessLevel is set to token-based

This commit is contained in:
Shane Kilkelly 2017-10-12 15:47:29 +01:00
parent 9a7c8c5842
commit dcf601fe80
3 changed files with 13 additions and 10 deletions

View file

@ -133,15 +133,19 @@ module.exports = CollaboratorsHandler =
getProjectsUserIsMemberOf: (user_id, fields, callback = (error, {readAndWrite:[],readOnly:[],tokenReadAndWrite:[],tokenReadOnly:[]}) ->) -> getProjectsUserIsMemberOf: (user_id, fields, callback = (error, {readAndWrite:[],readOnly:[],tokenReadAndWrite:[],tokenReadOnly:[]}) ->) ->
async.mapLimit( async.mapLimit(
[ [
'collaberator_refs', {collaberator_refs: user_id},
'readOnly_refs', {readOnly_refs: user_id},
'tokenAccessReadAndWrite_refs', {
'tokenAccessReadOnly_refs' tokenAccessReadAndWrite_refs: user_id,
publicAccesLevel: PublicAccessLevels.TOKEN_BASED
},
{
tokenAccessReadOnly_refs: user_id,
publicAccesLevel: PublicAccessLevels.TOKEN_BASED
}
] ]
, 2 , 2
, (key, cb) -> , (query, cb) ->
query = {}
query[key] = user_id
Project.find query, fields, cb Project.find query, fields, cb
, (error, results) -> , (error, results) ->
return callback(error) if error? return callback(error) if error?

View file

@ -56,7 +56,6 @@ module.exports = ProjectGetter =
return callback(error) if error? return callback(error) if error?
CollaboratorsHandler.getProjectsUserIsMemberOf user_id, fields, (error, projects) -> CollaboratorsHandler.getProjectsUserIsMemberOf user_id, fields, (error, projects) ->
return callback(error) if error? return callback(error) if error?
# TODO: Add token projects too
callback null, ownedProjects, projects.readAndWrite, projects.readOnly, projects.tokenReadAndWrite, projects.tokenReadOnly callback null, ownedProjects, projects.readAndWrite, projects.readOnly, projects.tokenReadAndWrite, projects.tokenReadOnly

View file

@ -196,8 +196,8 @@ describe "CollaboratorsHandler", ->
@Project.find = sinon.stub() @Project.find = sinon.stub()
@Project.find.withArgs({collaberator_refs:@user_id}, @fields).yields(null, ["mock-read-write-project-1", "mock-read-write-project-2"]) @Project.find.withArgs({collaberator_refs:@user_id}, @fields).yields(null, ["mock-read-write-project-1", "mock-read-write-project-2"])
@Project.find.withArgs({readOnly_refs:@user_id}, @fields).yields(null, ["mock-read-only-project-1", "mock-read-only-project-2"]) @Project.find.withArgs({readOnly_refs:@user_id}, @fields).yields(null, ["mock-read-only-project-1", "mock-read-only-project-2"])
@Project.find.withArgs({tokenAccessReadAndWrite_refs:@user_id}, @fields).yields(null, ["mock-token-read-write-project-1", "mock-token-read-write-project-2"]) @Project.find.withArgs({tokenAccessReadAndWrite_refs:@user_id, publicAccesLevel: 'tokenBased'}, @fields).yields(null, ["mock-token-read-write-project-1", "mock-token-read-write-project-2"])
@Project.find.withArgs({tokenAccessReadOnly_refs:@user_id}, @fields).yields(null, ["mock-token-read-only-project-1", "mock-token-read-only-project-2"]) @Project.find.withArgs({tokenAccessReadOnly_refs:@user_id, publicAccesLevel: 'tokenBased'}, @fields).yields(null, ["mock-token-read-only-project-1", "mock-token-read-only-project-2"])
@CollaboratorHandler.getProjectsUserIsMemberOf @user_id, @fields, @callback @CollaboratorHandler.getProjectsUserIsMemberOf @user_id, @fields, @callback
it "should call the callback with the projects", -> it "should call the callback with the projects", ->