From bde0fe4ab3350fc1b135bbefd2db8031bcb4fef3 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Thu, 19 Jan 2017 19:11:00 +0000 Subject: [PATCH] Allow login during setup using a provided email or 2FA code --- Program.cs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Program.cs b/Program.cs index 8e4919c..535a67b 100644 --- a/Program.cs +++ b/Program.cs @@ -325,10 +325,29 @@ namespace SteamGuard var password = Console.ReadLine(); UserLogin login = new UserLogin(username, password); - Console.Write($"Logging in {username}... "); - LoginResult loginResult = login.DoLogin(); - Console.WriteLine(loginResult); - if (!login.LoggedIn) return; + string emailCode = null, twoFactorCode = null; + while (true) + { + login.EmailCode = emailCode; + login.TwoFactorCode = twoFactorCode; + Console.Write($"Logging in {username}... "); + LoginResult loginResult = login.DoLogin(); + Console.WriteLine(loginResult); + if (loginResult == LoginResult.NeedEmail) + { + Console.Write("Email code: "); + emailCode = Console.ReadLine(); + continue; + } + else if (loginResult == LoginResult.Need2FA) + { + Console.Write("2FA code: "); + twoFactorCode = Console.ReadLine(); + continue; + } + if (!login.LoggedIn) return; + break; + } AuthenticatorLinker linker = new AuthenticatorLinker(login.Session); AuthenticatorLinker.LinkResult linkResult = AuthenticatorLinker.LinkResult.GeneralFailure;