コード例 #1
0
        private async void SignInPassport()
        {
            if (_isExistingAccount)
            {
                if (await MicrosoftPassportHelper.GetPassportAuthenticationMessageAsync(_account))
                {
                    Frame.Navigate(typeof(Welcome), _account);
                }
            }
            else if (AccountHelper.ValidateAccountCredentials(UsernameTextBox.Text))
            {
                // Create and add a new local account
                _account = AccountHelper.AddAccount(UsernameTextBox.Text);
                Debug.WriteLine("Successfully signed in with traditional credentials and created local account instance!");

                if (await MicrosoftPassportHelper.CreatePassportKeyAsync(UsernameTextBox.Text))
                {
                    Debug.WriteLine("Successfully signed in with Microsoft Passport!");
                    Frame.Navigate(typeof(Welcome), _account);
                }
            }
            else
            {
                ErrorMessage.Text = "Invalid Credentials";
            }
        }
コード例 #2
0
        private void Button_Forget_User_Click(object sender, RoutedEventArgs e)
        {
            // Remove it from Microsoft Passport
            MicrosoftPassportHelper.RemovePassportAccountAsync(_activeAccount);

            // Remove it from the local accounts list and resave the updated list
            AccountHelper.RemoveAccount(_activeAccount);

            Debug.WriteLine("User " + _activeAccount.Username + " deleted.");
            Frame.Navigate(typeof(UserSelection));
        }
コード例 #3
0
 protected override async void OnNavigatedTo(NavigationEventArgs e)
 {
     // Check Microsoft Passport is setup and available on this machine
     if (await MicrosoftPassportHelper.MicrosoftPassportAvailableCheckAsync())
     {
         if (e.Parameter != null)
         {
             _isExistingAccount = true;
             // Set the account to the existing account being passed in
             _account             = (Account)e.Parameter;
             UsernameTextBox.Text = _account.Username;
             SignInPassport();
         }
     }
     else
     {
         // Microsoft Passport is not setup so inform the user
         PassportStatus.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 50, 170, 207));
         PassportStatusText.Text   = "Microsoft Passport is not setup!\n" +
                                     "Please go to Windows Settings and set up a PIN to use it.";
         PassportSignInButton.IsEnabled = false;
     }
 }
コード例 #4
0
        private async void RegisterButton_Click_Async(object sender, RoutedEventArgs e)
        {
            ErrorMessage.Text = "";

            //In the real world you would normally validate the entered credentials and information before
            //allowing a user to register a new account.
            //For this sample though we will skip that step and just register an account if username is not null.

            if (!string.IsNullOrEmpty(UsernameTextBox.Text))
            {
                //Register a new account
                _account = AccountHelper.AddAccount(UsernameTextBox.Text);
                //Register new account with Microsoft Passport
                await MicrosoftPassportHelper.CreatePassportKeyAsync(_account.Username);

                //Navigate to the Welcome Screen.
                Frame.Navigate(typeof(Welcome), _account);
            }
            else
            {
                ErrorMessage.Text = "Please enter a username";
            }
        }