private async void RequestConsent_Click(object sender, RoutedEventArgs e) { RequestConsentButton.IsEnabled = false; // Request the user's consent using Windows Hello via biometric verification or a PIN. string message = "Please confirm your identity to complete this (pretend) in-app purchase."; UserConsentVerificationResult consentResult = await UserConsentVerifier.RequestVerificationAsync(message); switch (consentResult) { case UserConsentVerificationResult.Verified: rootPage.NotifyUser("Pretend in-app purchase was successful.", NotifyType.StatusMessage); break; case UserConsentVerificationResult.DeviceNotPresent: rootPage.NotifyUser("No PIN or biometric found, please set one up.", NotifyType.ErrorMessage); break; case UserConsentVerificationResult.Canceled: rootPage.NotifyUser("User consent verification canceled.", NotifyType.ErrorMessage); break; default: rootPage.NotifyUser("User consent verification is currently unavailable.", NotifyType.ErrorMessage); break; } RequestConsentButton.IsEnabled = true; }
public async Task <UserConsentVerificationResult> GetRequestUserConsentVerificationAsync(string message) { UserConsentVerificationResult consentResult = await UserConsentVerifier.RequestVerificationAsync(message); return(consentResult); }
/// <summary> /// Verifies the user's identity. /// </summary> /// <returns>True if identity was verified, else false.</returns> public async Task <bool> VerifyIdentityAsync() { UserConsentVerificationResult result = await UserConsentVerifier.RequestVerificationAsync( this.resourceProvider.GetString(PromptResourceKey) ); return(result == UserConsentVerificationResult.Verified); }
/// <summary> /// This is the click handler for the 'Request Consent' button. It requests consent from the current user. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void RequestConsent_Click(object sender, RoutedEventArgs e) { Button b = sender as Button; b.IsEnabled = false; if (!String.IsNullOrEmpty(Message.Text)) { try { // Request the logged on user's consent using Windows Hello via biometric verification or a PIN. UserConsentVerificationResult consentResult = await Windows.Security.Credentials.UI.UserConsentVerifier.RequestVerificationAsync(Message.Text); switch (consentResult) { case UserConsentVerificationResult.Verified: { rootPage.NotifyUser("User consent verified!", NotifyType.StatusMessage); break; } case UserConsentVerificationResult.DeviceNotPresent: { rootPage.NotifyUser("No PIN or biometric found, please set one up.", NotifyType.ErrorMessage); break; } case UserConsentVerificationResult.Canceled: { rootPage.NotifyUser("User consent verification canceled.", NotifyType.ErrorMessage); break; } default: { rootPage.NotifyUser("User consent verification is currently unavailable.", NotifyType.ErrorMessage); break; } } } catch (Exception ex) { rootPage.NotifyUser("Request current user's consent failed with exception. Operation: RequestVerificationAsync, Exception: " + ex.ToString(), NotifyType.ErrorMessage); } finally { b.IsEnabled = true; } } else { rootPage.NotifyUser("Empty Message String. Enter prompt string in the Message text field.", NotifyType.ErrorMessage); b.IsEnabled = true; } }
public async Task <bool> Authenticate() { UserConsentVerificationResult res = await UserConsentVerifier.RequestVerificationAsync("tSecret"); switch (res) { case UserConsentVerificationResult.Verified: return(true); default: return(false); } }
/// <summary> /// Verify login with Windows Hello /// </summary> private async void WindowsHelloLogin() { UserConsentVerificationResult consentResult = await UserConsentVerifier.RequestVerificationAsync(Resources.WindowsHelloLoginMessage); if (consentResult.Equals(UserConsentVerificationResult.Verified)) { var dbHash = await App.Repository.Password.GetAsync(); var secretService = App.Current.Container.Resolve <ISecretService>(); //TODO check if this is a problem if (!await CheckNavigationRequest(secretService.Helper.ReadSecret(Constants.ContainerName, dbHash.Hash))) { ShowLoginError(); } } }
private async void buttonRequestConsent_Click(object sender, RoutedEventArgs e) { try { UserConsentVerificationResult consentResult = await UserConsentVerifier.RequestVerificationAsync("我要做一些操作,您同意吗?"); switch (consentResult) { case UserConsentVerificationResult.Verified: // 验证通过 lblMsg.Text += "UserConsentVerificationResult.Verified"; break; case UserConsentVerificationResult.DeviceBusy: lblMsg.Text += "UserConsentVerificationResult.DeviceBusy"; break; case UserConsentVerificationResult.DeviceNotPresent: lblMsg.Text += "UserConsentVerificationResult.DeviceNotPresent"; break; case UserConsentVerificationResult.DisabledByPolicy: lblMsg.Text += "UserConsentVerificationResult.DisabledByPolicy"; break; case UserConsentVerificationResult.NotConfiguredForUser: lblMsg.Text += "UserConsentVerificationResult.NotConfiguredForUser"; break; case UserConsentVerificationResult.RetriesExhausted: lblMsg.Text += "UserConsentVerificationResult.RetriesExhausted"; break; case UserConsentVerificationResult.Canceled: // 验证取消 lblMsg.Text += "UserConsentVerificationResult.Canceled"; break; default: break; } } catch (Exception ex) { lblMsg.Text += ex.ToString(); } lblMsg.Text += "\n"; }
private async void CreateAccountButton_Click(object sender, RoutedEventArgs e) { if (personalInfo == null) { var uri = new Uri(@"https://app.n26.com/register"); await Windows.System.Launcher.LaunchUriAsync(uri); } else { UserConsentVerificationResult consentResult = await UserConsentVerifier.RequestVerificationAsync("Please authenticate to log in!"); if (consentResult.Equals(UserConsentVerificationResult.Verified)) { SendLogin(GetCredentialFromLocker().UserName, GetCredentialFromLocker().Password); } } }
// Add reference to Windows.winmd, typically c:\program files (x86)\windows kits\10\UnionMetadata\{version} // Add reference to System.Runtime.WindowsRuntime.dll, typically C:\Windows\Microsoft.NET\Framework\v4.0.30319 public async Task <bool> WindowsHelloSignInAsync() { // Check the availability of Windows Hello authentication through User Consent Verifier. UserConsentVerifierAvailability consentAvailability = await UserConsentVerifier.CheckAvailabilityAsync(); if (consentAvailability == UserConsentVerifierAvailability.Available) { // Request the user's consent using Windows Hello via biometric verification or a PIN. string message = "Please confirm your identity to login to this app"; UserConsentVerificationResult consentResult = await UserConsentVerifier.RequestVerificationAsync(message); switch (consentResult) { case UserConsentVerificationResult.Verified: System.Diagnostics.Debug.WriteLine("User verified"); return(true); } } return(false); }
public async Task <bool> RequestUserConsentVerificationAsync(string message) { try { UserConsentVerificationResult consentResult = await UserConsentVerifier.RequestVerificationAsync(message); if (consentResult == UserConsentVerificationResult.Verified) { return(true); } else { return(false); } } catch { return(false); } }
public static async Task <bool> Auth() { if (await WindowsHelloAvailableCheckAsync()) { UserConsentVerificationResult consentResult = await UserConsentVerifier.RequestVerificationAsync(""); if (consentResult != UserConsentVerificationResult.Verified) { return(false); } else { return(true); } } else { await new MessageDialog("Failed loading Windows Hello service", "Failed").ShowAsync(); await Launcher.LaunchUriAsync(new Uri("ms-settings:signinoptions")); } return(false); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { personalInfo = await api.LoadMe(); if (personalInfo != null) { WelcomeBlock.Text = string.Format("Welcome back, {0}!", personalInfo.firstName); UsernameBox.Text = personalInfo.email; CreateAccountButton.Content = "Login using Windows Hello"; } else { return; } var loginCredential = GetCredentialFromLocker(); if (loginCredential == null) { return; } UserConsentVerificationResult consentResult = await UserConsentVerifier.RequestVerificationAsync(string.Format("Welcome back, {0}!", personalInfo.firstName)); if (consentResult.Equals(UserConsentVerificationResult.Verified)) { ProgressWorking.Visibility = Visibility.Visible; if (await api.RenewToken()) { LoadData(); } else { await new MessageDialog("We've lost authentication. Please log in again!").ShowAsync(); } } }
private async Task Authenticate() { VisualStateManager.GoToState(this, "InProgress", false); UserConsentVerificationResult result = await winHelloService.AuthenticateAsync(); Analytics.TrackEvent("Windows Hello authentication complete", new Dictionary <string, string>() { { "Result", result.ToString() } }); switch (result) { case UserConsentVerificationResult.Verified: ((App)Application.Current).NavigateToFirstPage(arguments, true); return; case UserConsentVerificationResult.DeviceNotPresent: case UserConsentVerificationResult.NotConfiguredForUser: case UserConsentVerificationResult.DisabledByPolicy: case UserConsentVerificationResult.DeviceBusy: WindowsHelloAuthError.Visibility = Visibility.Visible; break; } VisualStateManager.GoToState(this, "Default", false); }
/// <summary> /// This is the click handler for the 'Request Consent' button. It requests consent from the current user. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void RequestConsent_Click(object sender, RoutedEventArgs e) { Button b = sender as Button; b.IsEnabled = false; if (!String.IsNullOrEmpty(Message.Text)) { try { // Request the currently logged on user's consent via fingerprint swipe UserConsentVerificationResult consentResult = await UserConsentVerifier.RequestVerificationAsync(Message.Text); switch (consentResult) { case UserConsentVerificationResult.Verified: { rootPage.NotifyUser("User's presence verified.", NotifyType.StatusMessage); break; } case UserConsentVerificationResult.DeviceBusy: { rootPage.NotifyUser("Biometric device is busy.", NotifyType.ErrorMessage); break; } case UserConsentVerificationResult.DeviceNotPresent: { rootPage.NotifyUser("No biometric device found.", NotifyType.ErrorMessage); break; } case UserConsentVerificationResult.DisabledByPolicy: { rootPage.NotifyUser("Biometrics is disabled by policy.", NotifyType.ErrorMessage); break; } case UserConsentVerificationResult.NotConfiguredForUser: { rootPage.NotifyUser("User has no fingeprints registered.", NotifyType.ErrorMessage); break; } case UserConsentVerificationResult.RetriesExhausted: { rootPage.NotifyUser("Too many failed attempts.", NotifyType.ErrorMessage); break; } case UserConsentVerificationResult.Canceled: { rootPage.NotifyUser("Consent request prompt was canceled.", NotifyType.ErrorMessage); break; } default: { rootPage.NotifyUser("Consent verification with fingerprints is currently unavailable.", NotifyType.ErrorMessage); break; } } } catch (Exception ex) { rootPage.NotifyUser("Request current user's consent failed with exception. Operation: RequestVerificationAsync, Exception: " + ex.ToString(), NotifyType.ErrorMessage); } finally { b.IsEnabled = true; } } else { rootPage.NotifyUser("Empty Message String. Enter prompt string in the Message text field.", NotifyType.ErrorMessage); b.IsEnabled = true; } }