next-auth icon indicating copy to clipboard operation
next-auth copied to clipboard

next-auth v5 no longer works with multiple credentials providers

Open chungweileong94 opened this issue 2 years ago • 2 comments

Environment

System: OS: macOS 14.2.1 CPU: (8) arm64 Apple M1 Memory: 829.22 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.19.0 - ~/Library/Caches/fnm_multishells/1647_1705584306483/bin/node Yarn: 1.22.21 - ~/Library/Caches/fnm_multishells/1647_1705584306483/bin/yarn npm: 10.2.3 - ~/Library/Caches/fnm_multishells/1647_1705584306483/bin/npm pnpm: 8.14.0 - ~/Library/Caches/fnm_multishells/1647_1705584306483/bin/pnpm bun: 1.0.22 - /opt/homebrew/bin/bun Browsers: Safari: 17.2.1 npmPackages: next: 14.0.4 => 14.0.4 next-auth: 5.0.0-beta.5 => 5.0.0-beta.5 react: ^18 => 18.2.0

Reproduction URL

https://github.com/chungweileong94/nextauth-multi-credential-bug

Describe the issue

According to the documentation, we should able to create multiple credentials providers in Next Auth v5.

However, as soon as we add a second credentials provider, the server signIn function from NextAuth(...) will stop working. Even if I just add a unique id to the credentials provider, it will result the same issue too.

Also note that this was working fine in NextAuth v4

How to reproduce

  1. Create at least two credentials providers with unique ID.
  2. Call the signIn function from NextAuth(...), with the corresponding credential provider ID.

Expected behavior

It should sign-in properly.

chungweileong94 avatar Jan 18 '24 14:01 chungweileong94

@chungweileong94 What is the solution for this, can we use multiple credentials provider?

pgupta1795 avatar Jan 24 '24 09:01 pgupta1795

@pgupta1795 it was fixed in #9471. However, it has yet to be released.

For now, you can use patch-package to patch it, until the proper fix is released.

[email protected]

chungweileong94 avatar Jan 24 '24 09:01 chungweileong94