Passing an object to the authorize function via credentials #2656
-
Question 💬I'm trying to pass some of the user field values from the database to the session variable, using Credentials provider. Since I'm using MongoDB, I do not want to hard-code the fields, as some fields might not even exist for other users. That's why I'm trying the But unfortunately, I see nothing more than a string that looks like: How to reproduce ☕️Let's assume we have an object like:
If you try using this Contributing 🙌🏽I am willing to contribute as long as this is a bug or a missing feature that needs to be added. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Check out the docs https://next-auth.js.org/providers/credentials you can submit any form fields you want to, but the object has to be flat and defined in the credentials field in your provider config. Everything sent this way will be passed to the authorize callback as the first argument: https://github.com/nextauthjs/next-auth/blob/main/src/server/routes/callback.js#L334-L340 |
Beta Was this translation helpful? Give feedback.
Check out the docs https://next-auth.js.org/providers/credentials
you can submit any form fields you want to, but the object has to be flat and defined in the credentials field in your provider config.
Everything sent this way will be passed to the authorize callback as the first argument:
https://github.com/nextauthjs/next-auth/blob/main/src/server/routes/callback.js#L334-L340