From bf9896a7123330fe17ed2a919ac70e9985d20bbf Mon Sep 17 00:00:00 2001 From: Jesse Cardone Date: Thu, 29 Jun 2023 17:12:32 -0400 Subject: [PATCH] Handle issue where steam fails to login due to incorrect device codes --- .../UserFormAuthenticator.cs | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Steam Desktop Authenticator/UserFormAuthenticator.cs b/Steam Desktop Authenticator/UserFormAuthenticator.cs index d5d56ddf..5aac92e7 100644 --- a/Steam Desktop Authenticator/UserFormAuthenticator.cs +++ b/Steam Desktop Authenticator/UserFormAuthenticator.cs @@ -1,12 +1,14 @@ using SteamAuth; using SteamKit2.Authentication; using System.Threading.Tasks; +using System.Windows.Forms; namespace Steam_Desktop_Authenticator { internal class UserFormAuthenticator : IAuthenticator { private SteamGuardAccount account; + private int deviceCodesGenerated = 0; public UserFormAuthenticator(SteamGuardAccount account) { @@ -20,12 +22,31 @@ public Task AcceptDeviceConfirmationAsync() public async Task GetDeviceCodeAsync(bool previousCodeWasIncorrect) { - return await account.GenerateSteamGuardCodeAsync(); + // If a code fails wait 30 seconds for a new one to regenerate + if (previousCodeWasIncorrect) + { + // After 2 tries tell the user that there seems to be an issue + if (deviceCodesGenerated > 2) + MessageBox.Show("There seems to be an issue logging into your account with these two factor codes. Are you sure SDA is still your authenticator?"); + + await Task.Delay(30000); + } + + string deviceCode = await account.GenerateSteamGuardCodeAsync(); + deviceCodesGenerated++; + + return deviceCode; } public Task GetEmailCodeAsync(string email, bool previousCodeWasIncorrect) { - InputForm emailForm = new InputForm("Enter the code sent to your email:"); + string message = "Enter the code sent to your email:"; + if (previousCodeWasIncorrect) + { + message = "The code you provided was invalid. Enter the code sent to your email:"; + } + + InputForm emailForm = new InputForm(message); emailForm.ShowDialog(); return Task.FromResult(emailForm.txtBox.Text); }