Change anonToken and such to anonymousAccessToken

This commit is contained in:
Shane Kilkelly 2017-10-20 10:10:21 +01:00
parent eab77aba91
commit 0e44b319db
7 changed files with 9 additions and 9 deletions

View file

@ -303,7 +303,7 @@ module.exports = ProjectController =
privilegeLevel: privilegeLevel privilegeLevel: privilegeLevel
chatUrl: Settings.apis.chat.url chatUrl: Settings.apis.chat.url
anonymous: anonymous anonymous: anonymous
anonToken: req._anonToken anonymousAccessToken: req._anonymousAccessToken
languages: Settings.languages languages: Settings.languages
themes: THEME_LIST themes: THEME_LIST
maxDocLength: Settings.max_doc_length maxDocLength: Settings.max_doc_length

View file

@ -44,7 +44,7 @@ module.exports = TokenAccessController =
logger.log {token, projectId: project._id}, logger.log {token, projectId: project._id},
"allow anonymous read-and-write token access" "allow anonymous read-and-write token access"
TokenAccessHandler.grantSessionTokenAccess(req, project._id, token) TokenAccessHandler.grantSessionTokenAccess(req, project._id, token)
req._anonToken = token req._anonymousAccessToken = token
return TokenAccessController._loadEditor(project._id, req, res, next) return TokenAccessController._loadEditor(project._id, req, res, next)
else else
logger.log {token, projectId: project._id}, logger.log {token, projectId: project._id},
@ -80,7 +80,7 @@ module.exports = TokenAccessController =
logger.log {userId, projectId: project._id}, logger.log {userId, projectId: project._id},
"adding anonymous user to project with readOnly token" "adding anonymous user to project with readOnly token"
TokenAccessHandler.grantSessionTokenAccess(req, project._id, token) TokenAccessHandler.grantSessionTokenAccess(req, project._id, token)
req._anonToken = token req._anonymousAccessToken = token
return TokenAccessController._loadEditor(project._id, req, res, next) return TokenAccessController._loadEditor(project._id, req, res, next)
else else
if project.owner_ref.toString() == userId if project.owner_ref.toString() == userId

View file

@ -55,7 +55,7 @@ module.exports = TokenAccessHandler =
getRequestToken: (req, projectId) -> getRequestToken: (req, projectId) ->
token = ( token = (
req?.session?.anonTokenAccess?[projectId.toString()] or req?.session?.anonTokenAccess?[projectId.toString()] or
req?.headers['x-sl-anon-token'] req?.headers['x-sl-anonymous-access-token']
) )
return token return token

View file

@ -118,7 +118,7 @@ block requirejs
window.user = data.user; window.user = data.user;
window.csrfToken = "!{csrfToken}"; window.csrfToken = "!{csrfToken}";
window.anonymous = #{anonymous}; window.anonymous = #{anonymous};
window.anonToken = "#{anonToken}"; window.anonymousAccessToken = "#{anonymousAccessToken}";
window.maxDocLength = #{maxDocLength}; window.maxDocLength = #{maxDocLength};
window.trackChangesState = data.trackChangesState; window.trackChangesState = data.trackChangesState;
window.showTrackChangesOnboarding = #{!!showTrackChangesOnboarding}; window.showTrackChangesOnboarding = #{!!showTrackChangesOnboarding};

View file

@ -157,8 +157,8 @@ define [], () ->
data = { data = {
project_id: @ide.project_id project_id: @ide.project_id
} }
if window.anonToken if window.anonymousAccessToken
data.anonToken = window.anonToken data.anonymousAccessToken = window.anonymousAccessToken
@ide.socket.emit 'joinProject', data, (err, project, permissionsLevel, protocolVersion) => @ide.socket.emit 'joinProject', data, (err, project, permissionsLevel, protocolVersion) =>
if err? or !project? if err? or !project?
return @reportConnectionError(err) return @reportConnectionError(err)

View file

@ -501,7 +501,7 @@ describe "TokenAccessController", ->
it 'should pass control to loadEditor', (done) -> it 'should pass control to loadEditor', (done) ->
expect(@req.params.Project_id).to.equal @projectId.toString() 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.callCount).to.equal 1
expect(@ProjectController.loadEditor.calledWith(@req, @res, @next)).to.equal true expect(@ProjectController.loadEditor.calledWith(@req, @res, @next)).to.equal true
done() done()

View file

@ -73,7 +73,7 @@ try_anon_content_access = (user, project_id, token, test, callback) ->
pass: settings.apis.web.pass pass: settings.apis.web.pass
sendImmediately: true sendImmediately: true
headers: headers:
'x-sl-anon-token': token 'x-sl-anonymous-access-token': token
json: true json: true
jar: false jar: false
}, (error, response, body) -> }, (error, response, body) ->