Allow login during setup using a provided email or 2FA code

This commit is contained in:
Vladimir Panteleev 2017-01-19 19:11:00 +00:00
parent 7aa5e40d20
commit bde0fe4ab3

View file

@ -325,10 +325,29 @@ namespace SteamGuard
var password = Console.ReadLine(); var password = Console.ReadLine();
UserLogin login = new UserLogin(username, password); UserLogin login = new UserLogin(username, password);
string emailCode = null, twoFactorCode = null;
while (true)
{
login.EmailCode = emailCode;
login.TwoFactorCode = twoFactorCode;
Console.Write($"Logging in {username}... "); Console.Write($"Logging in {username}... ");
LoginResult loginResult = login.DoLogin(); LoginResult loginResult = login.DoLogin();
Console.WriteLine(loginResult); 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; if (!login.LoggedIn) return;
break;
}
AuthenticatorLinker linker = new AuthenticatorLinker(login.Session); AuthenticatorLinker linker = new AuthenticatorLinker(login.Session);
AuthenticatorLinker.LinkResult linkResult = AuthenticatorLinker.LinkResult.GeneralFailure; AuthenticatorLinker.LinkResult linkResult = AuthenticatorLinker.LinkResult.GeneralFailure;