Skip to content

Fix passkey login error experience #62480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

MackinnonBuck
Copy link
Member

Fix passkey login error experience

Improves passkey login error messages and fixes an issue where passkey autofill failure can result in the page refreshing indefinitely.

Description

If the browser is missing certain passkey APIs, passkey autofill (conditional mediation) can fail. This causes the page to refresh to display the error, but the refresh itself causes passkey autofill to be attempted again. As a result, the page continues to refresh indefinitely.

In addition, displayed error messages are technical and not user-friendly. If an error does occur during passkey login, the user should have a clear understanding of the problem, and the technical details should be logged to the browser console rather than displayed in the UI.

This PR makes the following changes:

  1. A more friendly error message is displayed if passkey login fails due to the authenticator failing to authenticate the user.
    Before:
    authenticator_failure_before
    After:
    authenticator_failure_after
  2. If the browser is missing passkey features, the error message clearly states this.
    Before:
    missing_features_before
    After:
    missing_features_after
  3. If any type of passkey failure occurs during passkey autofill, don't relay the error to the user. This both provides a better UX because the user likely isn't expecting to see an error for an action they didn't initiate, and it also fixes the indefinite refresh bug.

Fixes https://github.com/dotnet/aspnetcore-manualtests/issues/3693

@MackinnonBuck MackinnonBuck added the area-identity Includes: Identity and providers label Jun 26, 2025
return;
}
formData.append(`${this.attrs.name}.Error`, error.message);
console.error(error);
const errorMessage = error.name === 'NotAllowedError' ? 'Unable to authenticate.' : error.message;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should put something in the error message to indicate that there's more information in the developer console. And now that Login.razor doesn't add anything to the message mentioning "passkey", I wonder if we should mention that here.

Suggested change
const errorMessage = error.name === 'NotAllowedError' ? 'Unable to authenticate.' : error.message;
const errorMessage = error.name === 'NotAllowedError' ? 'Unable to authenticate with passkey. See developer console for more details.' : error.message;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe we could improve the wording here. The thing about "Unable to authenticate with passkey" is that IMO it could be interpreted as if passkey was obtained, but we just couldn't authenticate with it (implying a possible error on the server). Whereas, what actually happened is that the authenticator couldn't authenticate the user, so no passkey was provided to the browser. Maybe something like "No passkey was provided by the authenticator" could work?

And regarding "See developer console for more details" - this is definitely helpful to the developer, but might it be unusual to display this to the user? The fact that this error shows up in a user-facing part of the UI makes me a little hesitant to put that there. I guess the developer could always remove that bit if they want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-identity Includes: Identity and providers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants