-
Notifications
You must be signed in to change notification settings - Fork 995
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
fix(dbAuth): Fix WebAuthn when authModelAccessor is set to a custom value #11605
fix(dbAuth): Fix WebAuthn when authModelAccessor is set to a custom value #11605
Conversation
@Josh-Walker-GM Please, let me know if anything needs to be changed, I would be happy to help release it as soon as possible. Don't really want to push on this, but this is holding us a little bit back, because we are migrating an existing app to Redwood and User table is already taken for other data. |
where: { [webAuthnOptions.credentialFields.id]: credentialId }, | ||
}) | ||
.user() | ||
const credential = await this.dbCredentialAccessor.findUnique({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching to findUnique
over findFirst
could potentially be breaking for someone that didn't have a unique, or some other equivalent, index on the database column.
I'm happy to make this change in a minor/patch. Not having a unique constraint on your webauthn id field feels like an underlying issue in the users code. Our generator/setup tool adds an @id
on the prisma model so would include an index as needed here.
Thanks @antonmoiseev! I'll get this out in the 8.3.0 release which I expect to go out in the next 24 hours or so |
…alue (#11605) - Instead of directly accessing auth model with hardcoded `user()` name, use `authModelAccessor` from DbAuthHandler options. - Also replaces `findFirst()` with `findUnique()` - we are querying data by the primary key. Feels semantically more correct, though may have no practical difference, I would expect Postgres to optimize query anyway if the only provided "where" criteria is PK.
user()
name, useauthModelAccessor
from DbAuthHandler options.findFirst()
withfindUnique()
- we are querying data by the primary key. Feels semantically more correct, though may have no practical difference, I would expect Postgres to optimize query anyway if the only provided "where" criteria is PK.