fix: Added ServerAuthFailed bool to Basic Authenticator

Fixes #2621
This commit is contained in:
MrGadget1024 2021-04-06 00:02:51 -04:00
parent 5fee51ada0
commit 6c5934f731

View File

@ -13,6 +13,9 @@ public class BasicAuthenticator : NetworkAuthenticator
public string username;
public string password;
// this is set if authentication fails to prevent garbage AuthRequestMessage spam
bool ServerAuthFailed;
#region Messages
public struct AuthRequestMessage : NetworkMessage
@ -101,7 +104,13 @@ public void OnAuthRequestMessage(NetworkConnection conn, AuthRequestMessage msg)
conn.isAuthenticated = false;
// disconnect the client after 1 second so that response message gets delivered
StartCoroutine(DelayedDisconnect(conn, 1));
if (!ServerAuthFailed)
{
// set this false so this coroutine can only be started once
ServerAuthFailed = true;
StartCoroutine(DelayedDisconnect(conn, 1));
}
}
}