private async void FinaliseResponse(AuthenticatorLinker.FinalizeResult response) { if (response == AuthenticatorLinker.FinalizeResult.BadSMSCode) { ErrorLabel.Text = "Bad Code"; SMSCode.Text = ""; Progress.Visibility = Visibility.Collapsed; LoginBtn.Visibility = ErrorLabel.Visibility = Visibility.Visible; } else if (response == AuthenticatorLinker.FinalizeResult.UnableToGenerateCorrectCodes || response == AuthenticatorLinker.FinalizeResult.GeneralFailure) { // Go back to main app screen on unknown failure var dialog = new MessageDialog("Unknown error linking authenticator"); dialog.Title = "Error"; dialog.Commands.Add(new UICommand("Ok")); await dialog.ShowAsync(); Frame.Navigate(typeof(MainPage)); } else if (response == AuthenticatorLinker.FinalizeResult.Success) { Storage.PushStore(linker.LinkedAccount); Frame.Navigate(typeof(MainPage)); } }
private async void LinkResponseReal(AuthenticatorLinker.LinkResult linkResponse) { bool firstRun = PhoneNumGrid.Visibility == Visibility.Collapsed; Progress.Visibility = ErrorLabel.Visibility = SMSGrid.Visibility = PhoneNumGrid.Visibility = RevocationGrid.Visibility = Visibility.Collapsed; if (linkResponse == AuthenticatorLinker.LinkResult.MustProvidePhoneNumber) { ErrorLabel.Text = "Enter Phone Number"; if (!firstRun) { ErrorLabel.Visibility = Visibility.Visible; } PhoneNum.Text = ""; PhoneNumGrid.Visibility = Visibility.Visible; } else if (linkResponse == AuthenticatorLinker.LinkResult.MustRemovePhoneNumber) { PhoneNum.Text = ""; linker.PhoneNumber = ""; linker.AddAuthenticator(LinkResponse); } else if (linkResponse == AuthenticatorLinker.LinkResult.GeneralFailure || linkResponse == AuthenticatorLinker.LinkResult.AuthenticatorPresent) { // Possibly because of rate limiting etc, force user to start process again manually var dialog = new MessageDialog(linkResponse == AuthenticatorLinker.LinkResult.GeneralFailure ? "Unknown error linking authenticator" : "You already have another device set up as an authenticator. Remove it from your account and try again."); dialog.Title = "Error"; dialog.Commands.Add(new UICommand("Ok")); await dialog.ShowAsync(); Frame.Navigate(typeof(MainPage)); } else if (linkResponse == AuthenticatorLinker.LinkResult.AwaitingFinalization) { Storage.PushStore(linker.LinkedAccount); RevocationGrid.Visibility = Visibility.Visible; RevocationCode.Text = linker.LinkedAccount.RevocationCode; } LoginBtn.Visibility = Visibility.Visible; }
private void DoUnlink(IUICommand cmd) { account.DeactivateAuthenticator(async response => { if (response) { account.FullyEnrolled = false; Storage.PushStore(account); await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { SteamGuardButton_Click(null, null); }); } else { var dialog = new MessageDialog("Failed to unlink authenticator"); dialog.Title = "Error"; dialog.Commands.Add(new UICommand("Ok")); await dialog.ShowAsync(); } }); }
private void ProcessLoginResponse(LoginResult response) { CaptchaText.Text = ""; HideAll(); Progress.IsEnabled = false; LoginBtn.Visibility = Visibility.Visible; if (response == LoginResult.NeedEmail) { ErrorLabel.Text = "Need 2FA"; EmailCode.Text = ""; EmailGrid.Visibility = ErrorLabel.Visibility = Visibility.Visible; } else if (responses.ContainsKey(response)) { ErrorLabel.Text = responses[response]; LoginGrid.Visibility = ErrorLabel.Visibility = Visibility.Visible; } else if (response == LoginResult.Need2FA) { SteamGuardAccount account = Storage.SGAFromStore(UserName.Text); if ((login.TwoFactorCode == null || login.TwoFactorCode.Length == 0) && account != null) { Progress.Visibility = LoginGrid.Visibility = Visibility.Visible; LoginBtn.Visibility = Visibility.Collapsed; account.GenerateSteamGuardCode(async code => { if (code == null || code.Length == 0) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { login.TwoFactorCode = " "; ProcessLoginResponse(LoginResult.Need2FA); }); return; } login.TwoFactorCode = code; login.DoLogin(async res => { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { ProcessLoginResponse(res); }); }); }); } else { ErrorLabel.Text = "Need 2FA"; TwoFactorCode.Text = ""; TwoFactorGrid.Visibility = ErrorLabel.Visibility = Visibility.Visible; } } else if (response == LoginResult.NeedCaptcha) { ErrorLabel.Text = "Are you human?"; CaptchaText.Text = ""; CaptchaGrid.Visibility = ErrorLabel.Visibility = Visibility.Visible; Uri myUri = new Uri("https://steamcommunity.com/login/rendercaptcha/?gid=" + login.CaptchaGID, UriKind.Absolute); BitmapImage bmi = new BitmapImage(); bmi.CreateOptions = BitmapCreateOptions.IgnoreImageCache; bmi.UriSource = myUri; Captcha.Source = bmi; } else if (response == LoginResult.LoginOkay) { Storage.PushStore(login.Session); LoginBtn.Visibility = Visibility.Collapsed; Frame.Navigate(typeof(MainPage), login.Session); } }