diff --git a/.gitignore b/.gitignore index 739e65f..277cae8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ bin/ obj/ .idea/ SteamAuth/SteamAuth/packages/ +test_maFiles/ *.deb \ No newline at end of file diff --git a/Program.cs b/Program.cs index 851bb2d..c4eab85 100644 --- a/Program.cs +++ b/Program.cs @@ -364,29 +364,40 @@ namespace SteamGuard var password = Utils.ReadLineSecure(); UserLogin login = new UserLogin(username, password); - string emailCode = null, twoFactorCode = null; - while (true) + LoginResult loginResult; + do { - login.EmailCode = emailCode; - login.TwoFactorCode = twoFactorCode; Console.Write($"Logging in {username}... "); - LoginResult loginResult = login.DoLogin(); + loginResult = login.DoLogin(); Console.WriteLine(loginResult); - if (loginResult == LoginResult.NeedEmail) + switch (loginResult) { - Console.Write("Email code: "); - emailCode = Console.ReadLine(); - continue; + case LoginResult.NeedEmail: + Console.Write("Email code: "); + login.EmailCode = Console.ReadLine(); + break; + case LoginResult.Need2FA: + Console.Write("2FA code: "); + login.TwoFactorCode = Console.ReadLine(); + break; + case LoginResult.NeedCaptcha: + Console.WriteLine($"Please open: https://steamcommunity.com/public/captcha.php?gid={login.CaptchaGID}"); + Console.Write("Captcha text: "); + login.CaptchaText = Console.ReadLine(); + break; + case LoginResult.BadCredentials: + Console.WriteLine("error: Bad Credentials"); + return; + case LoginResult.TooManyFailedLogins: + Console.WriteLine("error: Too many failed logins. Wait a bit before trying again."); + return; + case LoginResult.LoginOkay: + break; + default: + Console.WriteLine($"Unknown login result: {loginResult}"); + break; } - else if (loginResult == LoginResult.Need2FA) - { - Console.Write("2FA code: "); - twoFactorCode = Console.ReadLine(); - continue; - } - if (!login.LoggedIn) return; - break; - } + } while (loginResult != LoginResult.LoginOkay); AuthenticatorLinker linker = new AuthenticatorLinker(login.Session); AuthenticatorLinker.LinkResult linkResult = AuthenticatorLinker.LinkResult.GeneralFailure; @@ -407,6 +418,10 @@ namespace SteamGuard linker.PhoneNumber = phonenumber; } while (!PhoneNumberOkay(phonenumber)); break; + case AuthenticatorLinker.LinkResult.MustConfirmEmail: + Console.WriteLine("Check your email. Before continuing, click the link in the email to confirm your phone number. Press enter to continue..."); + Console.ReadLine(); + break; case AuthenticatorLinker.LinkResult.MustRemovePhoneNumber: linker.PhoneNumber = null; break; diff --git a/SteamAuth b/SteamAuth index 2f9f8b9..e061952 160000 --- a/SteamAuth +++ b/SteamAuth @@ -1 +1 @@ -Subproject commit 2f9f8b92cd365414196b90cae3ab25ff430a4fab +Subproject commit e0619528fbe8f4c6f74135283b3f991219e73cf4