Cleaner code
This commit is contained in:
@@ -32,14 +32,10 @@ function userLogin(client, username, password, cb) {
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Ensure this user is not already logged in.
|
// 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;
|
const existingClientConnection = clientConnections.find(cc => {
|
||||||
clientConnections.forEach(function connEntry(cc) {
|
return user !== cc.user && // not current connection
|
||||||
if(cc.user !== user && cc.user.userId === user.userId) {
|
user.userId === cc.user.userId; // ...but same user
|
||||||
existingClientConnection = cc;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if(existingClientConnection) {
|
if(existingClientConnection) {
|
||||||
|
|||||||
Reference in New Issue
Block a user