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
chatUrl: Settings.apis.chat.url
anonymous: anonymous
anonToken: req._anonToken
anonymousAccessToken: req._anonymousAccessToken
languages: Settings.languages
themes: THEME_LIST
maxDocLength: Settings.max_doc_length

View file

@ -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

View file

@ -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

View file

@ -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};

View file

@ -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)

View file

@ -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()

View file

@ -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) ->