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

[Bug]: DbAuthHandler doesn't allow renaming User model #8743

Closed
1 task done
antonmoiseev opened this issue Jun 26, 2023 · 1 comment · Fixed by #9788
Closed
1 task done

[Bug]: DbAuthHandler doesn't allow renaming User model #8743

antonmoiseev opened this issue Jun 26, 2023 · 1 comment · Fixed by #9788
Assignees
Labels
bug/confirmed We have confirmed this is a bug

Comments

@antonmoiseev
Copy link
Contributor

What's not working?

DbAuthHandler explicitly references user() model in a Prisma query which doesn't allow renaming Prisma User model into anything else. This is where it's happening (line 810):

user = await this.dbCredentialAccessor
.findFirst({
where: { [webAuthnOptions.credentialFields.id]: credentialId },
})
.user()

Instead it should use authModelAccessor to access the table.

How do we reproduce the bug?

  1. Rename the User model
  2. Add a user to the database
  3. Start the app and try to login into it

What's your environment? (If it applies)

System:
    OS: macOS 13.4.1
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.20.1 - /private/var/folders/fn/8llygws922d451wc05087z4r0000gn/T/xfs-b6f22933/node
    Yarn: 3.5.0 - /private/var/folders/fn/8llygws922d451wc05087z4r0000gn/T/xfs-b6f22933/yarn
  Databases:
    SQLite: 3.39.5 - /usr/bin/sqlite3
  Browsers:
    Chrome: 114.0.5735.133
    Safari: 16.5.1
  npmPackages:
    @redwoodjs/auth-dbauth-setup: 5.3.2 => 5.3.2
    @redwoodjs/core: 5.3.2 => 5.3.2

Are you interested in working on this?

  • I'm interested in working on this
@antonmoiseev antonmoiseev added the bug/needs-info More information is needed for reproduction label Jun 26, 2023
@Josh-Walker-GM Josh-Walker-GM self-assigned this Nov 15, 2023
@Josh-Walker-GM Josh-Walker-GM added bug/confirmed We have confirmed this is a bug and removed bug/needs-info More information is needed for reproduction labels Nov 15, 2023
@Josh-Walker-GM
Copy link
Collaborator

Thanks @antonmoiseev! I just reproduced this following your instructions.

I quickly noticed that this line appears to be related too:

userId: user[this.options.authFields.id],

I'm happy to help out some more if you still want to try out a PR for this. Otherwise I'll probably try to pick this up myself soon.

@Josh-Walker-GM Josh-Walker-GM changed the title [Bug?]: DbAuthHandler doesn't allow renaming User model [Bug]: DbAuthHandler doesn't allow renaming User model Nov 15, 2023
Josh-Walker-GM added a commit that referenced this issue Jan 2, 2024
**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
jtoar pushed a commit that referenced this issue Jan 3, 2024
**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
jtoar pushed a commit that referenced this issue Jan 3, 2024
**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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/confirmed We have confirmed this is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants