mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-29 20:12:20 +00:00
Merge pull request #7 from sharelatex/bg-add-authentication-events-on-connect
send connectionAccepted/Rejected events on connect
This commit is contained in:
commit
02194f7f86
1 changed files with 12 additions and 1 deletions
|
@ -39,11 +39,22 @@ module.exports = Router =
|
||||||
app.post "/drain", httpAuth, HttpApiController.startDrain
|
app.post "/drain", httpAuth, HttpApiController.startDrain
|
||||||
|
|
||||||
session.on 'connection', (error, client, session) ->
|
session.on 'connection', (error, client, session) ->
|
||||||
|
if client? and error?.message?.match(/could not look up session by key/)
|
||||||
|
logger.err err: error, client: client?, session: session?, "invalid session"
|
||||||
|
# tell the client to reauthenticate if it has an invalid session key
|
||||||
|
client.emit("connectionRejected", {message: "invalid session"})
|
||||||
|
client.disconnect()
|
||||||
|
return
|
||||||
|
|
||||||
if error?
|
if error?
|
||||||
logger.err err: error, "error when client connected"
|
logger.err err: error, client: client?, session: session?, "error when client connected"
|
||||||
|
client?.emit("connectionRejected", {message: "error"})
|
||||||
client?.disconnect()
|
client?.disconnect()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# send positive confirmation that the client has a valid connection
|
||||||
|
client.emit("connectionAccepted")
|
||||||
|
|
||||||
metrics.inc('socket-io.connection')
|
metrics.inc('socket-io.connection')
|
||||||
|
|
||||||
logger.log session: session, client_id: client.id, "client connected"
|
logger.log session: session, client_id: client.id, "client connected"
|
||||||
|
|
Loading…
Reference in a new issue