Example #1
0
        private void ForgetButton_Click(object sender, RoutedEventArgs e)
        {
            //Remove it from Windows Hello
            MicrosoftPassport.RemovePassportAccountAsync(_activeAccount);

            Debug.WriteLine("User " + _activeAccount.Username + " deleted.");

            //Navigate back to UserSelection page.
            Frame.Navigate(typeof(UserSelection));
        }
Example #2
0
        private async void SignInPassportAsync()
        {
            if (_isExistingAccount)
            {
                if (await MicrosoftPassport.GetPassportAuthenticationMessageAsync(_account))
                {
                    Frame.Navigate(typeof(Welcome), _account);
                }
            }

            else if (AuthService.Instance.ValidateCredentials(UsernameTextBox.Text, PasswordBox.Password))
            {
                Guid userId = AuthService.Instance.GetUserId(UsernameTextBox.Text);

                if (userId != Guid.Empty)
                {
                    //Now that the account exists on server try and create the necessary passport details and add them to the account
                    bool isSuccessful = await MicrosoftPassport.CreatePassportKeyAsync(userId, UsernameTextBox.Text);

                    if (isSuccessful)
                    {
                        Debug.WriteLine("Successfully signed in with Windows Hello!");
                        //Navigate to the Welcome Screen.
                        _account = AuthService.Instance.GetUserAccount(userId);
                        Frame.Navigate(typeof(Welcome), _account);
                    }
                    else
                    {
                        //The passport account creation failed.
                        //Remove the account from the server as passport details were not configured
                        AuthService.Instance.PassportRemoveUser(userId);

                        ErrorMessage.Text = "Account aanmaken mislukt!";
                    }
                }
            }
            else
            {
                ErrorMessage.Text = "Ongeldige inloggegevens";
            }
        }
Example #3
0
        private void Button_Forget_Device_Click(object sender, RoutedEventArgs e)
        {
            PassportDevice selectedDevice = UserListView.SelectedItem as PassportDevice;

            if (selectedDevice != null)
            {
                //Remove it from Windows Hello
                MicrosoftPassport.RemovePassportDevice(_activeAccount, selectedDevice.DeviceId);

                Debug.WriteLine("User " + _activeAccount.Username + " deleted.");

                if (!UserListView.Items.Any())
                {
                    //Navigate back to UserSelection page.
                    Frame.Navigate(typeof(UserSelection));
                }
            }
            else
            {
                ForgetDeviceErrorTextBlock.Visibility = Visibility.Visible;
            }
        }
Example #4
0
 protected override async void OnNavigatedTo(NavigationEventArgs e)
 {
     // Check Windows Hello is setup and available on this machine
     if (await MicrosoftPassport.MicrosoftPassportAvailableCheckAsync())
     {
         if (e.Parameter != null)
         {
             _isExistingAccount = true;
             // Set the account to the existing account being passed in
             _account             = (User)e.Parameter;
             UsernameTextBox.Text = _account.Username;
             SignInPassportAsync();
         }
     }
     else
     {
         //Windows Hello 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;
     }
 }
Example #5
0
        private async void RegisterButton_Click_Async(object sender, RoutedEventArgs e)
        {
            ErrorMessage.Text = "";

            //Validate entered credentials are acceptable
            if (!string.IsNullOrEmpty(UsernameTextBox.Text))
            {
                //Register an Account on the AuthService so that we can get back a userId
                AuthService.Instance.Register(UsernameTextBox.Text);
                Guid userId = AuthService.Instance.GetUserId(UsernameTextBox.Text);

                if (userId != Guid.Empty)
                {
                    //Now that the account exists on server try and create the necessary passport details and add them to the account
                    bool isSuccessful = await MicrosoftPassport.CreatePassportKeyAsync(userId, UsernameTextBox.Text);

                    if (isSuccessful)
                    {
                        //Navigate to the Welcome Screen.
                        Frame.Navigate(typeof(Welcome), AuthService.Instance.GetUserAccount(userId));
                    }
                    else
                    {
                        //The passport account creation failed.
                        //Remove the account from the server as passport details were not configured
                        AuthService.Instance.PassportRemoveUser(userId);

                        ErrorMessage.Text = "Aanmaak account mislukt!";
                    }
                }
            }
            else
            {
                ErrorMessage.Text = "Vul een gebruikersnaam in!";
            }
        }