NET8 Maui IFingerprint doesn't stop to ask for authentication

63 views Asked by At

In my NET8 MAUI application, I added Plugin.Fingerprint. When a user wants to login in the app, I redirect the user to a LoginPage.

private readonly IFingerprint fingerprint;
public LoginPage(IFingerprint fingerprint)
{
    InitializeComponent();

    this. Fingerprint = fingerprint;
}

async Task<bool> IsBiometricAvailable()
{
    return await fingerprint.IsAvailableAsync(true);
}

protected override async void OnAppearing()
{
    base.OnAppearing();

    vm.Clean();

    var isAvailable = await IsBiometricAvailable();
}

private async Task ValidateBiometrics() {
    var request = new AuthenticationRequestConfiguration("Access", 
        "Use your biometric to access the app.");
    var result = await fingerprint.AuthenticateAsync(request);
    if (result.Authenticated)
        GotoMainPage();
}

private async void imageButtonFinger_Clicked(object sender, EventArgs e)
{
    await ValidateBiometrics();
}

private void GotoMainPage()
{
    Application.Current.MainPage = new AppShell();
}

From this code, I expect that only when I click the imageButtonFinger, the app calls the ValidateBiometrics to start the process of the biometric authentication. The real behaviour is that after checking IsBiometricAvailable, the app starts to ask again and again for biometric authentication.

This behaviour continues also if I change page.

0

There are 0 answers