mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Use custom header, send anonToken in payload to joinProject
This commit is contained in:
parent
34d4d1360f
commit
9f24f696a5
3 changed files with 7 additions and 4 deletions
|
@ -51,6 +51,7 @@ module.exports = TokenAccessController =
|
||||||
"adding anonymous user to project with readOnly token"
|
"adding anonymous user to project with readOnly token"
|
||||||
TokenAccessHandler.grantSessionReadOnlyTokenAccess(req, project._id, token)
|
TokenAccessHandler.grantSessionReadOnlyTokenAccess(req, project._id, token)
|
||||||
req.params.Project_id = project._id.toString()
|
req.params.Project_id = project._id.toString()
|
||||||
|
req._anonToken = token
|
||||||
return ProjectController.loadEditor(req, res, next)
|
return ProjectController.loadEditor(req, res, next)
|
||||||
else
|
else
|
||||||
logger.log {userId, projectId: project._id},
|
logger.log {userId, projectId: project._id},
|
||||||
|
@ -61,7 +62,6 @@ module.exports = TokenAccessController =
|
||||||
"error adding user to project with readAndWrite token"
|
"error adding user to project with readAndWrite token"
|
||||||
return next(err)
|
return next(err)
|
||||||
req.params.Project_id = project._id.toString()
|
req.params.Project_id = project._id.toString()
|
||||||
req._anonToken = token
|
|
||||||
return ProjectController.loadEditor(req, res, next)
|
return ProjectController.loadEditor(req, res, next)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ define [
|
||||||
"ngTagsInput"
|
"ngTagsInput"
|
||||||
]).config ($qProvider, sixpackProvider, $httpProvider)->
|
]).config ($qProvider, sixpackProvider, $httpProvider)->
|
||||||
if window.anonToken
|
if window.anonToken
|
||||||
$httpProvider.defaults.headers.common['Authorization'] = window.anonToken
|
$httpProvider.defaults.headers.common['x-sl-anon-token'] = window.anonToken
|
||||||
$qProvider.errorOnUnhandledRejections(false)
|
$qProvider.errorOnUnhandledRejections(false)
|
||||||
sixpackProvider.setOptions({
|
sixpackProvider.setOptions({
|
||||||
debug: false
|
debug: false
|
||||||
|
|
|
@ -154,9 +154,12 @@ define [], () ->
|
||||||
# Note: if the "joinProject" message doesn't reach the server
|
# Note: if the "joinProject" message doesn't reach the server
|
||||||
# (e.g. if we are in a disconnected state at this point) the
|
# (e.g. if we are in a disconnected state at this point) the
|
||||||
# callback will never be executed
|
# callback will never be executed
|
||||||
@ide.socket.emit 'joinProject', {
|
data = {
|
||||||
project_id: @ide.project_id
|
project_id: @ide.project_id
|
||||||
}, (err, project, permissionsLevel, protocolVersion) =>
|
}
|
||||||
|
if window.anonToken
|
||||||
|
data.anonToken = window.anonToken
|
||||||
|
@ide.socket.emit 'joinProject', data, (err, project, permissionsLevel, protocolVersion) =>
|
||||||
if err? or !project?
|
if err? or !project?
|
||||||
return @reportConnectionError(err)
|
return @reportConnectionError(err)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue