Beispiel #1
0
        private async void FinaliseResponse(AuthenticatorLinker.FinalizeResult response)
        {
            switch (response)
            {
            case AuthenticatorLinker.FinalizeResult.BadSMSCode:
                this.ErrorLabel.Text        = StringResourceLoader.GetString("BadCode");
                this.SmsCode.Text           = string.Empty;
                this.Progress.Visibility    = Visibility.Collapsed;
                this.BtnContinue.Visibility = this.ErrorLabel.Visibility = Visibility.Visible;
                break;

            case AuthenticatorLinker.FinalizeResult.UnableToGenerateCorrectCodes:
            case AuthenticatorLinker.FinalizeResult.GeneralFailure:
                // Go back to main app screen on unknown failure

                var dialog = new MessageDialog(StringResourceLoader.GetString("Authenticator_Link_UnknownError_Message"))
                {
                    Title = StringResourceLoader.GetString("Authenticator_Link_UnknownError_Title")
                };
                dialog.Commands.Add(new UICommand(StringResourceLoader.GetString("UiCommand_Ok_Text")));
                await dialog.ShowAsync();

                this.Frame.Navigate(typeof(MainPage));
                break;

            case AuthenticatorLinker.FinalizeResult.Success:
                this.linker.LinkedAccount.PushStore();
                this.Frame.Navigate(typeof(MainPage));
                break;
            }
        }
Beispiel #2
0
        public LoginPage()
        {
            this.InitializeComponent();

            this.responses.Add(LoginResult.GeneralFailure, StringResourceLoader.GetString("LoginResult_GeneralFailure_Text"));
            this.responses.Add(LoginResult.BadRsa, StringResourceLoader.GetString("LoginResult_BadRSA_Text"));
            this.responses.Add(LoginResult.BadCredentials, StringResourceLoader.GetString("LoginResult_BadCredentials_Text"));
            this.responses.Add(LoginResult.TooManyFailedLogins, StringResourceLoader.GetString("LoginResult_TooManyFailedLogins_Text"));
        }
        private async void UnlinkBtn_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new MessageDialog(StringResourceLoader.GetString("Authenticator_Unlink_Prompt_Message"))
            {
                Title = StringResourceLoader.GetString("Authenticator_Unlink_Prompt_Title")
            };

            dialog.Commands.Add(new UICommand(StringResourceLoader.GetString("UiCommand_Ok_Text"), this.DoUnlink));
            dialog.Commands.Add(new UICommand(StringResourceLoader.GetString("UiCommand_Cancel_Text"))); // Take no action
            await dialog.ShowAsync();
        }
 private async void UnlinkFailed()
 {
     await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
     {
         var dialog = new MessageDialog(StringResourceLoader.GetString("Authenticator_Unlink_Failed_Message"))
         {
             Title = StringResourceLoader.GetString("Authenticator_Unlink_Failed_Title")
         };
         dialog.Commands.Add(new UICommand(StringResourceLoader.GetString("UiCommand_Ok_Text")));
         await dialog.ShowAsync();
     });
 }
        private void SteamGuardButton_Click(object sender, RoutedEventArgs e)
        {
            this.HideAll();
            if (this.account == null || !this.account.FullyEnrolled)
            {
                this.LinkGrid.Visibility = Visibility.Visible;
                return;
            }

            this.AccountText.Text = string.Format(
                StringResourceLoader.GetString("MainPage_AccountText_Format"),
                this.account.DisplayName ?? string.Empty,
                this.account.AccountName ?? this.account.Session.Username ?? string.Empty
                );

            this.SteamGuardGrid.Visibility = Visibility.Visible;
            this.steamGuardUpdate_Tick(null, null);
        }
        public void ReloadList()
        {
            this.listElems.Clear();

            this.steamGuardUpdate_Tick(null, null);

            Dictionary <ulong, SessionData> accs = Storage.GetAccounts();

            if (accs.Count < 1)
            {
                return;
            }

            foreach (ulong steamId in accs.Keys)
            {
                var usr = new User(steamId, accs[steamId].LastCurrent, StringResourceLoader.GetString("GeneratingCode_Ellipsis"));
                this.listElems.Add(steamId, usr);
            }

            this.AccountList.ItemsSource = this.listElems.Values.OrderByDescending(item => item.LastCurrent).ToList();

            UserSummary.GetSummaries(this.web, accs.First().Value, accs.Keys.ToArray(), this.SummariesCallback);
        }
        private async void LogoutButton_Click(object sender, RoutedEventArgs e)
        {
            var element     = (FrameworkElement)e.OriginalSource;
            var selectedOne = (User)element.DataContext;

            if (selectedOne == null)
            {
                return;
            }

            var dialog = new MessageDialog(StringResourceLoader.GetString("User_Logout_Prompt_Message"))
            {
                Title = StringResourceLoader.GetString("User_Logout_Prompt_Title")
            };

            dialog.Commands.Add(new UICommand(StringResourceLoader.GetString("UiCommand_Yes_Text"), cmd =>
            {
                Storage.Logout(selectedOne.SteamId);
                this.AccountList.Items?.Remove(selectedOne);
            }));
            dialog.Commands.Add(new UICommand(StringResourceLoader.GetString("UiCommand_No_Text"))); // Take no action
            await dialog.ShowAsync();
        }
Beispiel #8
0
        private async void LinkResponseReal(AuthenticatorLinker.LinkResult linkResponse)
        {
            bool phoneWasVis  = this.PhoneNumGrid.Visibility == Visibility.Visible;
            bool familyWasVis = this.FamilyGrid.Visibility == Visibility.Visible;

            this.LayoutRoot.RowDefinitions[1].Height = GridLength.Auto;
            this.Progress.Visibility = this.ErrorLabel.Visibility = this.SmsGrid.Visibility = this.PhoneNumGrid.Visibility = this.RevocationGrid.Visibility = this.FamilyGrid.Visibility = Visibility.Collapsed;

            switch (linkResponse)
            {
            case AuthenticatorLinker.LinkResult.MustProvidePhoneNumber:
                this.ErrorLabel.Text = StringResourceLoader.GetString("EnterPhoneNumber");
                if (phoneWasVis)
                {
                    this.ErrorLabel.Visibility = Visibility.Visible;
                }
                this.PhoneNum.Text           = string.Empty;
                this.PhoneNumGrid.Visibility = Visibility.Visible;
                break;

            case AuthenticatorLinker.LinkResult.MustRemovePhoneNumber:
                this.PhoneNum.Text      = string.Empty;
                this.linker.PhoneNumber = string.Empty;
                this.linker.AddAuthenticator(this.web, this.LinkResponse);
                break;

            case AuthenticatorLinker.LinkResult.FamilyViewEnabled:
                this.ErrorLabel.Text = StringResourceLoader.GetString("FamilyPinIncorrect");
                if (familyWasVis)
                {
                    this.ErrorLabel.Visibility = Visibility.Visible;
                }
                this.FamilyPin.Password    = string.Empty;
                this.FamilyGrid.Visibility = Visibility.Visible;
                break;

            case AuthenticatorLinker.LinkResult.GeneralFailure:
            case AuthenticatorLinker.LinkResult.AuthenticatorPresent:
                // Possibly because of rate limiting etc, force user to start process again manually

                var dialog = new MessageDialog(linkResponse == AuthenticatorLinker.LinkResult.GeneralFailure ? StringResourceLoader.GetString("Authenticator_Link_UnknownError_Message") : StringResourceLoader.GetString("Authenticator_Link_AlreadyLinked_Message"))
                {
                    Title = StringResourceLoader.GetString("Authenticator_Link_UnknownError_Title")
                };
                dialog.Commands.Add(new UICommand(StringResourceLoader.GetString("UiCommand_Ok_Text")));
                await dialog.ShowAsync();

                this.Frame.Navigate(typeof(MainPage));
                break;

            case AuthenticatorLinker.LinkResult.AwaitingFinalization:
                this.linker.LinkedAccount.PushStore();

                this.RevocationGrid.Visibility           = Visibility.Visible;
                this.LayoutRoot.RowDefinitions[1].Height = new GridLength(1, GridUnitType.Star);
                this.RevocationCode.Text = this.linker.LinkedAccount.RevocationCode;
                break;
            }

            this.BtnContinue.Visibility = Visibility.Visible;
        }
Beispiel #9
0
        private void ProcessLoginResponse(LoginResult response)
        {
            this.CaptchaText.Text = string.Empty;
            this.HideAll();
            this.Progress.IsEnabled  = false;
            this.LoginBtn.Visibility = Visibility.Visible;

            if (response == LoginResult.NeedEmail)
            {
                this.ErrorLabel.Text      = StringResourceLoader.GetString("Need2Fa");
                this.EmailCode.Text       = string.Empty;
                this.EmailGrid.Visibility = this.ErrorLabel.Visibility = Visibility.Visible;
            }
            else if (this.responses.ContainsKey(response))
            {
                this.ErrorLabel.Text      = this.responses[response];
                this.LoginGrid.Visibility = this.ErrorLabel.Visibility = Visibility.Visible;
            }
            else if (response == LoginResult.Need2Fa)
            {
                SteamGuardAccount account = Storage.GetSteamGuardAccount(this.UserName.Text);
                if (string.IsNullOrWhiteSpace(this.userLogin.TwoFactorCode) && account != null)
                {
                    this.Progress.Visibility = this.LoginGrid.Visibility = Visibility.Visible;
                    this.LoginBtn.Visibility = Visibility.Collapsed;

                    account.GenerateSteamGuardCode(this.web, async code =>
                    {
                        if (string.IsNullOrWhiteSpace(code))
                        {
                            await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                            {
                                this.userLogin.TwoFactorCode = "-";
                                this.ProcessLoginResponse(LoginResult.Need2Fa);
                            });
                            return;
                        }

                        this.userLogin.TwoFactorCode = code;

                        this.userLogin.DoLogin(this.web, async res =>
                        {
                            await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                            {
                                this.ProcessLoginResponse(res);
                            });
                        });
                    });
                }
                else
                {
                    this.ErrorLabel.Text          = StringResourceLoader.GetString("Need2Fa");
                    this.TwoFactorCode.Text       = string.Empty;
                    this.TwoFactorGrid.Visibility = this.ErrorLabel.Visibility = Visibility.Visible;
                }
            }
            else if (response == LoginResult.NeedCaptcha)
            {
                this.ErrorLabel.Text        = StringResourceLoader.GetString("AreYouHuman");
                this.CaptchaText.Text       = string.Empty;
                this.CaptchaGrid.Visibility = this.ErrorLabel.Visibility = Visibility.Visible;

                var myUri = new Uri("https://steamcommunity.com/login/rendercaptcha/?gid=" + this.userLogin.CaptchaGID, UriKind.Absolute);
                var bmi   = new BitmapImage()
                {
                    CreateOptions = BitmapCreateOptions.IgnoreImageCache,
                    UriSource     = myUri
                };
                this.Captcha.Source = bmi;
            }
            else if (response == LoginResult.LoginOkay)
            {
                Storage.PushStore(this.userLogin.Session);
                Storage.SetCurrentUser(this.userLogin.Session.SteamID);
                this.Frame.Navigate(typeof(MainPage), this.userLogin.Session);
            }
        }