From 6c5934f731730b867d44873c14c663499a8eefd9 Mon Sep 17 00:00:00 2001 From: MrGadget1024 Date: Tue, 6 Apr 2021 00:02:51 -0400 Subject: [PATCH] fix: Added ServerAuthFailed bool to Basic Authenticator Fixes #2621 --- Assets/Mirror/Authenticators/BasicAuthenticator.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Assets/Mirror/Authenticators/BasicAuthenticator.cs b/Assets/Mirror/Authenticators/BasicAuthenticator.cs index 88923105e..35c3cdb88 100644 --- a/Assets/Mirror/Authenticators/BasicAuthenticator.cs +++ b/Assets/Mirror/Authenticators/BasicAuthenticator.cs @@ -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)); + } } }