summaryrefslogtreecommitdiff
path: root/src/node/handler/PadMessageHandler.js
diff options
context:
space:
mode:
authorClark Boylan <clark.boylan@gmail.com>2015-05-21 08:46:54 -0700
committerClark Boylan <clark.boylan@gmail.com>2015-06-24 15:18:35 -0700
commit10605956760d0a83766ff8ecab2d64c452c7205a (patch)
tree04fafe15d9bec639f7ac4c72d941aa8ab8f56618 /src/node/handler/PadMessageHandler.js
parent444634b588a2edde03989ff290a4cf4668b32eb2 (diff)
downloadetherpad-lite-10605956760d0a83766ff8ecab2d64c452c7205a.zip
Check for valid session in handleUserInfoUpdate
Address issue 2674 by checking that the session is valid and has a valid author and padId before using it to update the userInfo for that session. Otherwise it is possible that by the time we try to update a session with new userInfo that session has disconnected and is no longer available to be updated. Without this commit the etherpad-lite service gracefully shutsdown whenever this happens.
Diffstat (limited to 'src/node/handler/PadMessageHandler.js')
-rw-r--r--src/node/handler/PadMessageHandler.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js
index 0172400b..248dc128 100644
--- a/src/node/handler/PadMessageHandler.js
+++ b/src/node/handler/PadMessageHandler.js
@@ -544,14 +544,22 @@ function handleUserInfoUpdate(client, message)
return;
}
+ // Check that we have a valid session and author to update.
+ var session = sessioninfos[client.id];
+ if(!session || !session.author || !session.padId)
+ {
+ messageLogger.warn("Dropped message, USERINFO_UPDATE Session not ready." + message.data);
+ return;
+ }
+
//Find out the author name of this session
- var author = sessioninfos[client.id].author;
+ var author = session.author;
//Tell the authorManager about the new attributes
authorManager.setAuthorColorId(author, message.data.userInfo.colorId);
authorManager.setAuthorName(author, message.data.userInfo.name);
- var padId = sessioninfos[client.id].padId;
+ var padId = session.padId;
var infoMsg = {
type: "COLLABROOM",