Skip to content

Commit bf9896a

Browse files
committed
Handle issue where steam fails to login due to incorrect device codes
1 parent 0253c76 commit bf9896a

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

Steam Desktop Authenticator/UserFormAuthenticator.cs

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
using SteamAuth;
22
using SteamKit2.Authentication;
33
using System.Threading.Tasks;
4+
using System.Windows.Forms;
45

56
namespace Steam_Desktop_Authenticator
67
{
78
internal class UserFormAuthenticator : IAuthenticator
89
{
910
private SteamGuardAccount account;
11+
private int deviceCodesGenerated = 0;
1012

1113
public UserFormAuthenticator(SteamGuardAccount account)
1214
{
@@ -20,12 +22,31 @@ public Task<bool> AcceptDeviceConfirmationAsync()
2022

2123
public async Task<string> GetDeviceCodeAsync(bool previousCodeWasIncorrect)
2224
{
23-
return await account.GenerateSteamGuardCodeAsync();
25+
// If a code fails wait 30 seconds for a new one to regenerate
26+
if (previousCodeWasIncorrect)
27+
{
28+
// After 2 tries tell the user that there seems to be an issue
29+
if (deviceCodesGenerated > 2)
30+
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?");
31+
32+
await Task.Delay(30000);
33+
}
34+
35+
string deviceCode = await account.GenerateSteamGuardCodeAsync();
36+
deviceCodesGenerated++;
37+
38+
return deviceCode;
2439
}
2540

2641
public Task<string> GetEmailCodeAsync(string email, bool previousCodeWasIncorrect)
2742
{
28-
InputForm emailForm = new InputForm("Enter the code sent to your email:");
43+
string message = "Enter the code sent to your email:";
44+
if (previousCodeWasIncorrect)
45+
{
46+
message = "The code you provided was invalid. Enter the code sent to your email:";
47+
}
48+
49+
InputForm emailForm = new InputForm(message);
2950
emailForm.ShowDialog();
3051
return Task.FromResult(emailForm.txtBox.Text);
3152
}

0 commit comments

Comments
 (0)