diff --git a/services/web/app/coffee/Features/Collaborators/CollaboratorsInviteController.coffee b/services/web/app/coffee/Features/Collaborators/CollaboratorsInviteController.coffee index c30acdb4cb..f86d46e151 100644 --- a/services/web/app/coffee/Features/Collaborators/CollaboratorsInviteController.coffee +++ b/services/web/app/coffee/Features/Collaborators/CollaboratorsInviteController.coffee @@ -56,7 +56,7 @@ module.exports = CollaboratorsInviteController = currentUser = req.session.user _renderInvalidPage = () -> logger.log {projectId, token}, "invite not valid, rendering not-valid page" - res.render "project/invite/not-valid" + res.render "project/invite/not-valid", {title: "Invalid Invite"} # get the target project Project.findOne {_id: projectId}, {owner_ref: 1, name: 1, collaberator_refs: 1, readOnly_refs: 1}, (err, project) -> if err? diff --git a/services/web/test/acceptance/coffee/ProjectInviteTests.coffee b/services/web/test/acceptance/coffee/ProjectInviteTests.coffee index c65e788398..f7512f5a57 100644 --- a/services/web/test/acceptance/coffee/ProjectInviteTests.coffee +++ b/services/web/test/acceptance/coffee/ProjectInviteTests.coffee @@ -91,7 +91,28 @@ describe "ProjectInviteTests", -> expect(body).to.match new RegExp("Project Invite - .*") cb() - # access the project page + # forbid access to the project page + (cb) => + @user.openProject @invite.projectId, (err) => + expect(err).to.be.instanceof Error + cb() + + ], done + ) + + it 'should render the invalid-invite page if the token is invalid', (done) -> + Async.series( + [ + # go to the invite page with an invalid token + (cb) => + link = @link.replace(@invite.token, 'not_a_real_token') + followInviteLink @user, link, (err, response, body) => + expect(err).to.be.oneOf [null, undefined] + expect(response.statusCode).to.equal 200 + expect(body).to.match new RegExp("Invalid Invite - .*") + cb() + + # forbid access to the project page (cb) => @user.openProject @invite.projectId, (err) => expect(err).to.be.instanceof Error