Пример #1
0
        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);
            }
        }