From f917ae978b072b15c50d61ceeeb15e4a7e1d0c4a Mon Sep 17 00:00:00 2001 From: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Tue, 2 Jan 2024 19:31:54 +0000 Subject: [PATCH] fix(dbAuth): Correct hardcoded DB column (#9788) **Problem** Logging in with webauthn enabled was broken when you had customised your schema to use different column names than the default. See #8743 for details. **Changes** 1. Alters the where clause to use the same column names as the create a few lines below. See: https://github.com/redwoodjs/redwood/blob/c7ae669e36c5e1b7edcd4ee5436558831bad94b8/packages/auth-providers/dbAuth/api/src/DbAuthHandler.ts#L979-L983 **Fixes** Fixes #8743 --- packages/auth-providers/dbAuth/api/src/DbAuthHandler.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/auth-providers/dbAuth/api/src/DbAuthHandler.ts b/packages/auth-providers/dbAuth/api/src/DbAuthHandler.ts index cd441d90e783..54e55cea4e71 100644 --- a/packages/auth-providers/dbAuth/api/src/DbAuthHandler.ts +++ b/packages/auth-providers/dbAuth/api/src/DbAuthHandler.ts @@ -972,8 +972,9 @@ export class DbAuthHandler< const existingDevice = await this.dbCredentialAccessor.findFirst({ where: { - id: plainCredentialId, - userId: user[this.options.authFields.id], + [this.options.webAuthn.credentialFields.id]: plainCredentialId, + [this.options.webAuthn.credentialFields.userId]: + user[this.options.authFields.id], }, })