question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Credentials does not work with `strategy` = `database`

See original GitHub issue

Description 🐜

Credentials don’t seem to work with strategy database and just tries to create a JWT token

https://github.com/nextauthjs/next-auth/blob/4824f8c02ad1b0799f4c15eea9c86e93fc5c72fc/src/core/routes/callback.ts#L398-L417

Is this a bug in your own project?

No

How to reproduce ☕️

  • Use Credentials provider
  • Use strategy database

Screenshots / Logs 📽

No response

Environment 🖥


  System:
    OS: macOS 12.0.1
    CPU: (8) x64 Apple M1
    Memory: 86.30 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 8.3.2 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Browsers:
    Chrome: 97.0.4692.99
    Firefox: 94.0.1
    Safari: 15.1
  npmPackages:
    next: ^12.0.7 => 12.0.7
    next-auth: ^4.1.2 => 0.0.0-semantically-released
    react: ^18.0.0-rc.0 => 18.0.0-rc.0

Contributing 🙌🏽

Yes, I am willing to help solve this bug in a PR

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

20reactions
balazsorban44commented, Jan 25, 2022

This is intended: https://next-auth.js.org/providers/credentials

We discourage the flow in general.

13reactions
jrmyiocommented, Feb 21, 2022

More people having issues which I think all are related to sessions not being supported for Credentials: https://github.com/nextauthjs/next-auth/issues/3970 https://github.com/nextauthjs/next-auth/discussions/3787

I somewhat understand using credentials is discouraged but at the of the day, most of the web still is and will continue to use password-based logins. Almost all providers next-auth implements in the end boil down to credentials being used in the provider’s ecosystem. For that reason it’s not a surprise many people start implementing credentials with next-auth.

I don’t really see what makes using the database session with credentials that much different then JWT. If intentional, why is one supported and the other one is not?

Inside https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/core/routes/callback.ts#L329 it seems almost all code should be there to get this to work, it’s mostly just that the callbackHandler() is never called for the credentials.

Read more comments on GitHub >

github_iconTop Results From Across the Web

6 steps for when remote desktop credentials are not working By
1. Make sure the credentials are correct ... The first step in troubleshooting the problem should always be to make sure that the...
Read more >
Set Credential & Connection Information for Report Data ...
A report server uses credentials to connect to external data sources that provide content to ... Credentials are not stored in the report....
Read more >
Next-Auth credentials not returning session and not storing ...
The CredentialsProvider is not compatible with Database Sessions. In order for credentials to work, you need to configure Next-Auth to use ...
Read more >
How to use Database Authentication in MicroStrategy 9.4.x
When the user selects a project, the credentials entered in step 1 are sent to the Intelligence Server for database authentication. The user...
Read more >
Configure credentials for an individual SQL Server resource
You can configure credentials to perform data protection jobs on individual SQL Server resource for each user. While you can configure the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found