From 0e44b319db70852e7a9adf911bbfcdf352ee923e Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Fri, 20 Oct 2017 10:10:21 +0100 Subject: [PATCH] Change `anonToken` and such to `anonymousAccessToken` --- .../web/app/coffee/Features/Project/ProjectController.coffee | 2 +- .../coffee/Features/TokenAccess/TokenAccessController.coffee | 4 ++-- .../app/coffee/Features/TokenAccess/TokenAccessHandler.coffee | 2 +- services/web/app/views/project/editor.pug | 2 +- .../web/public/coffee/ide/connection/ConnectionManager.coffee | 4 ++-- .../coffee/TokenAccess/TokenAccessControllerTests.coffee | 2 +- services/web/test/acceptance/coffee/TokenAccessTests.coffee | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/services/web/app/coffee/Features/Project/ProjectController.coffee b/services/web/app/coffee/Features/Project/ProjectController.coffee index 04576e8f84..928f52d4a9 100644 --- a/services/web/app/coffee/Features/Project/ProjectController.coffee +++ b/services/web/app/coffee/Features/Project/ProjectController.coffee @@ -303,7 +303,7 @@ module.exports = ProjectController = privilegeLevel: privilegeLevel chatUrl: Settings.apis.chat.url anonymous: anonymous - anonToken: req._anonToken + anonymousAccessToken: req._anonymousAccessToken languages: Settings.languages themes: THEME_LIST maxDocLength: Settings.max_doc_length diff --git a/services/web/app/coffee/Features/TokenAccess/TokenAccessController.coffee b/services/web/app/coffee/Features/TokenAccess/TokenAccessController.coffee index 25e3a9af27..97506c5f63 100644 --- a/services/web/app/coffee/Features/TokenAccess/TokenAccessController.coffee +++ b/services/web/app/coffee/Features/TokenAccess/TokenAccessController.coffee @@ -44,7 +44,7 @@ module.exports = TokenAccessController = logger.log {token, projectId: project._id}, "allow anonymous read-and-write token access" TokenAccessHandler.grantSessionTokenAccess(req, project._id, token) - req._anonToken = token + req._anonymousAccessToken = token return TokenAccessController._loadEditor(project._id, req, res, next) else logger.log {token, projectId: project._id}, @@ -80,7 +80,7 @@ module.exports = TokenAccessController = logger.log {userId, projectId: project._id}, "adding anonymous user to project with readOnly token" TokenAccessHandler.grantSessionTokenAccess(req, project._id, token) - req._anonToken = token + req._anonymousAccessToken = token return TokenAccessController._loadEditor(project._id, req, res, next) else if project.owner_ref.toString() == userId diff --git a/services/web/app/coffee/Features/TokenAccess/TokenAccessHandler.coffee b/services/web/app/coffee/Features/TokenAccess/TokenAccessHandler.coffee index 4862628858..b4d2f063f3 100644 --- a/services/web/app/coffee/Features/TokenAccess/TokenAccessHandler.coffee +++ b/services/web/app/coffee/Features/TokenAccess/TokenAccessHandler.coffee @@ -55,7 +55,7 @@ module.exports = TokenAccessHandler = getRequestToken: (req, projectId) -> token = ( req?.session?.anonTokenAccess?[projectId.toString()] or - req?.headers['x-sl-anon-token'] + req?.headers['x-sl-anonymous-access-token'] ) return token diff --git a/services/web/app/views/project/editor.pug b/services/web/app/views/project/editor.pug index 36fa910cfa..014933147c 100644 --- a/services/web/app/views/project/editor.pug +++ b/services/web/app/views/project/editor.pug @@ -118,7 +118,7 @@ block requirejs window.user = data.user; window.csrfToken = "!{csrfToken}"; window.anonymous = #{anonymous}; - window.anonToken = "#{anonToken}"; + window.anonymousAccessToken = "#{anonymousAccessToken}"; window.maxDocLength = #{maxDocLength}; window.trackChangesState = data.trackChangesState; window.showTrackChangesOnboarding = #{!!showTrackChangesOnboarding}; diff --git a/services/web/public/coffee/ide/connection/ConnectionManager.coffee b/services/web/public/coffee/ide/connection/ConnectionManager.coffee index ac79fbfa44..d996184e49 100644 --- a/services/web/public/coffee/ide/connection/ConnectionManager.coffee +++ b/services/web/public/coffee/ide/connection/ConnectionManager.coffee @@ -157,8 +157,8 @@ define [], () -> data = { project_id: @ide.project_id } - if window.anonToken - data.anonToken = window.anonToken + if window.anonymousAccessToken + data.anonymousAccessToken = window.anonymousAccessToken @ide.socket.emit 'joinProject', data, (err, project, permissionsLevel, protocolVersion) => if err? or !project? return @reportConnectionError(err) diff --git a/services/web/test/UnitTests/coffee/TokenAccess/TokenAccessControllerTests.coffee b/services/web/test/UnitTests/coffee/TokenAccess/TokenAccessControllerTests.coffee index 4e34c7904a..00e506fd6e 100644 --- a/services/web/test/UnitTests/coffee/TokenAccess/TokenAccessControllerTests.coffee +++ b/services/web/test/UnitTests/coffee/TokenAccess/TokenAccessControllerTests.coffee @@ -501,7 +501,7 @@ describe "TokenAccessController", -> it 'should pass control to loadEditor', (done) -> expect(@req.params.Project_id).to.equal @projectId.toString() - expect(@req._anonToken).to.equal @readOnlyToken + expect(@req._anonymousAccessToken).to.equal @readOnlyToken expect(@ProjectController.loadEditor.callCount).to.equal 1 expect(@ProjectController.loadEditor.calledWith(@req, @res, @next)).to.equal true done() diff --git a/services/web/test/acceptance/coffee/TokenAccessTests.coffee b/services/web/test/acceptance/coffee/TokenAccessTests.coffee index d1548fe234..9e7e0a441e 100644 --- a/services/web/test/acceptance/coffee/TokenAccessTests.coffee +++ b/services/web/test/acceptance/coffee/TokenAccessTests.coffee @@ -73,7 +73,7 @@ try_anon_content_access = (user, project_id, token, test, callback) -> pass: settings.apis.web.pass sendImmediately: true headers: - 'x-sl-anon-token': token + 'x-sl-anonymous-access-token': token json: true jar: false }, (error, response, body) ->