Skip to content
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

How to prevent creating a passkey if there was an error? #260

Closed
larrasu opened this issue Oct 25, 2024 · 5 comments
Closed

How to prevent creating a passkey if there was an error? #260

larrasu opened this issue Oct 25, 2024 · 5 comments

Comments

@larrasu
Copy link

larrasu commented Oct 25, 2024

I'm following nuxt-todo-passkeys. On the auth page, if a user already exists, it still creates a passkey. How do I avoid this?

@atinux
Copy link
Owner

atinux commented Oct 27, 2024

It does not create a new user either a passkey in database but show an error:

CleanShot.2024-10-27.at.14.41.40.mp4

@larrasu
Copy link
Author

larrasu commented Oct 27, 2024

What I mean is it still creates a passkey on the device. Here the todo-passkeys was able to create 2 passkeys on the device even if the user already exists.

Screen.Recording.2024-10-27.at.11.01.00.AM.mov

I was expecting something like this:

webauthn.mov

@atinux
Copy link
Owner

atinux commented Oct 30, 2024

cc @Gerbuuun

@Gerbuuun
Copy link
Contributor

Gerbuuun commented Oct 30, 2024

To prevent duplicate credentials, you should add existing credentials related to the given username to the excludeCredentials option in the getOptions function. I will create a PR to the nuxt-todo-passkeys with an example of how to do it after #266 is merged (which contains a type fix).

We might want to create an excludeCredentials function to the defineWebAuthnRegisterEventHandler just like the allowCredentials function in defineWebAuthnAuthenticateEventHandler.

edit: I added the excludeCredentials in the PR because otherwise the credential db query will run both on init and on verification. So the example will use the excludeCredentials function.

@atinux
Copy link
Owner

atinux commented Oct 31, 2024

v0.5.1 is out @Gerbuuun (thank you so much)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants