What does the database do exactly? #2182
Replies: 2 comments 1 reply
-
Just tested out some more. It's all very confusing. Now I've added my database URL (mongodb). I can login successfully, but upon inspecting the database, nothing has changed. I really think some more documentation is needed as to what the database integration does exactly, because it's pretty confusing. |
Beta Was this translation helpful? Give feedback.
-
It is our belief that people shouldn't implement their own auth solutions, so we have a limited built-in support, but it is fully possible to integrate with your backend, check these for more info: https://next-auth.js.org/faq#does-nextauthjs-support-signing-in-with-a-username-and-password https://next-auth.js.org/providers/credentials NextAuth.js supports to types of persisting mechanisms. JWT sessions and databases. In vas eof JWT, user data is persisted in a signed, optionally encrypted JWT token in a cookie. Some features (like email login) are only possible with a database though. (we have to persist the login token somewhere) in case of a database, you can still decide to use a JWT cookie session. The DB tables are for User, Account (think of OAuth profiles connected together through a user table), Session and VerificationRequest Here is a list of adapters we currently try to support https://next-auth.js.org/adapters/overview As an example, here is a schema for a Prisma adapter, it should hopefully give you an idea what is required: If you still struggle, please tell us which part of the docs is insufficient, or better yet, please open a PR with your suggestions! Thank you |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question 💬
I am trying to integrate Next-auth into an existing database. I have a table with users with whom I wish to log in. They have an e-mail and password.
I find it pretty difficult getting started on this library. Like for instance, database is mentioned several places, but you do not say anything about what it does exactly. I imagine it would maybe use it to look up the user e-mail to check if a user exists? Perhaps not? If so, how do I specify what table and field it should look in? I've look in both FAQ and the section related to databases.
Also it's quite confusing that a basic email & password provider is not more documented. I am aware that it might not be best practise (so is magic-password-less logins either I've read), but it is however, part of my scope, and must be a pretty standard requiremenet, at least still in 2021? ;)
Hope to receive some clarification here.
Beta Was this translation helpful? Give feedback.
All reactions