Merge pull request #13 from CyberShadow/pull-20170119-191048

Setup improvements and fixes
This commit is contained in:
Carson McManus 2017-01-20 18:51:09 -05:00 committed by GitHub
commit 71512e6634

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);
Console.Write($"Logging in {username}... "); string emailCode = null, twoFactorCode = null;
LoginResult loginResult = login.DoLogin(); while (true)
Console.WriteLine(loginResult); {
if (!login.LoggedIn) return; 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 linker = new AuthenticatorLinker(login.Session);
AuthenticatorLinker.LinkResult linkResult = AuthenticatorLinker.LinkResult.GeneralFailure; AuthenticatorLinker.LinkResult linkResult = AuthenticatorLinker.LinkResult.GeneralFailure;
@ -358,8 +377,22 @@ namespace SteamGuard
Console.WriteLine("error: Unable to add your phone number. Steam returned GeneralFailure"); Console.WriteLine("error: Unable to add your phone number. Steam returned GeneralFailure");
return; return;
case AuthenticatorLinker.LinkResult.AuthenticatorPresent: case AuthenticatorLinker.LinkResult.AuthenticatorPresent:
Console.WriteLine("error: Can't link authenticator, remove the previous authenticator."); Console.WriteLine("An authenticator is already present.");
return; Console.WriteLine("If you have the revocation code (Rxxxxx), this program can remove it for you.");
Console.Write("Would you like to remove the current authenticator using your revocation code? (y/n) ");
var answer = Console.ReadLine();
if (answer != "y")
continue;
Console.Write("Revocation code (Rxxxxx): ");
var revocationCode = Console.ReadLine();
var account = new SteamGuardAccount();
account.Session = login.Session;
account.RevocationCode = revocationCode;
if (account.DeactivateAuthenticator())
Console.WriteLine("Successfully deactivated the current authenticator.");
else
Console.WriteLine("Deactivating the current authenticator was unsuccessful.");
continue;
default: default:
Console.WriteLine($"error: Unexpected linker result: {linkResult}"); Console.WriteLine($"error: Unexpected linker result: {linkResult}");
return; return;
@ -370,7 +403,7 @@ namespace SteamGuard
if (Manifest.Entries.Count == 0) if (Manifest.Entries.Count == 0)
{ {
Console.WriteLine("Looks like we are setting up your first account."); Console.WriteLine("Looks like we are setting up your first account.");
passKey = Manifest.PromptSetupPassKey(); passKey = Manifest.PromptSetupPassKey(true);
} }
else if (Manifest.Entries.Count > 0 && Manifest.Encrypted) else if (Manifest.Entries.Count > 0 && Manifest.Encrypted)
{ {