Merge branch 'jpa-backport-126' into jpa-backport-113

This commit is contained in:
Jakob Ackermann 2020-06-22 17:04:40 +01:00
commit 7a114937a7
2 changed files with 4 additions and 5 deletions

View file

@ -55,6 +55,8 @@ module.exports = Router =
app.post "/client/:client_id/disconnect", httpAuth, HttpApiController.disconnectClient
session.on 'connection', (error, client, session) ->
# init client context, we may access it in Router._handleError before
# setting any values
client.ol_context = {}
client?.on "error", (err) ->
@ -113,13 +115,9 @@ module.exports = Router =
metrics.inc('socket-io.disconnect')
metrics.gauge('socket-io.clients', io.sockets.clients()?.length - 1)
cleanup = () ->
delete client.ol_context
WebsocketController.leaveProject io, client, (err) ->
if err?
Router._handleError cleanup, err, client, "leaveProject"
else
cleanup()
Router._handleError (() ->), err, client, "leaveProject"
# Variadic. The possible arguments:
# doc_id, callback

View file

@ -33,6 +33,7 @@ module.exports = WebsocketController =
logger.warn {err, project_id, user_id, client_id: client.id}, "user is not authorized to join project"
return callback(err)
client.ol_context = {}
client.ol_context["privilege_level"] = privilegeLevel
client.ol_context["user_id"] = user_id
client.ol_context["project_id"] = project_id