mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
PadMessageHandler: Fix readability of duplicate user check
This commit is contained in:
parent
00e7b04518
commit
b7de24c85f
1 changed files with 7 additions and 5 deletions
|
@ -847,13 +847,15 @@ const handleClientReady = async (socket, message) => {
|
||||||
// Check if this author is already on the pad, if yes, kick the other sessions!
|
// Check if this author is already on the pad, if yes, kick the other sessions!
|
||||||
const roomSockets = _getRoomSockets(pad.id);
|
const roomSockets = _getRoomSockets(pad.id);
|
||||||
|
|
||||||
for (const socket of roomSockets) {
|
for (const otherSocket of roomSockets) {
|
||||||
const sinfo = sessioninfos[socket.id];
|
// The user shouldn't have joined the room yet, but check anyway just in case.
|
||||||
|
if (otherSocket.id === socket.id) continue;
|
||||||
|
const sinfo = sessioninfos[otherSocket.id];
|
||||||
if (sinfo && sinfo.author === sessionInfo.author) {
|
if (sinfo && sinfo.author === sessionInfo.author) {
|
||||||
// fix user's counter, works on page refresh or if user closes browser window and then rejoins
|
// fix user's counter, works on page refresh or if user closes browser window and then rejoins
|
||||||
sessioninfos[socket.id] = {};
|
sessioninfos[otherSocket.id] = {};
|
||||||
socket.leave(padIds.padId);
|
otherSocket.leave(padIds.padId);
|
||||||
socket.json.send({disconnect: 'userdup'});
|
otherSocket.json.send({disconnect: 'userdup'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue