Fix bug with already logged in/connected check logic @ login

This commit is contained in:
Bryan Ashby 2017-01-11 22:48:04 -07:00
parent 1218fe65f9
commit 4c1c05e4da
1 changed files with 4 additions and 2 deletions

View File

@ -29,7 +29,7 @@ function userLogin(client, username, password, cb) {
// Loop through active connections -- which includes the current --
// and check for matching user ID. If the count is > 1, disallow.
//
let existingClientConnection =
let existingClientConnection;
clientConnections.forEach(function connEntry(cc) {
if(cc.user !== user && cc.user.userId === user.userId) {
existingClientConnection = cc;
@ -47,7 +47,9 @@ function userLogin(client, username, password, cb) {
var existingConnError = new Error('Already logged in as supplied user');
existingConnError.existingConn = true;
return cb(existingClientConnection);
// :TODO: We should use EnigError & pass existing connection as second param
return cb(existingConnError);
}