From 472968e81d08da6100f6158968821c1430af19de Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Wed, 21 Nov 2018 19:50:03 -0700 Subject: [PATCH] Cleaner code --- core/user_login.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/core/user_login.js b/core/user_login.js index c4f1bcf1..d08788f3 100644 --- a/core/user_login.js +++ b/core/user_login.js @@ -32,14 +32,10 @@ function userLogin(client, username, password, cb) { // // Ensure this user is not already logged in. - // Loop through active connections -- which includes the current -- - // and check for matching user ID. If the count is > 1, disallow. // - let existingClientConnection; - clientConnections.forEach(function connEntry(cc) { - if(cc.user !== user && cc.user.userId === user.userId) { - existingClientConnection = cc; - } + const existingClientConnection = clientConnections.find(cc => { + return user !== cc.user && // not current connection + user.userId === cc.user.userId; // ...but same user }); if(existingClientConnection) {