NextAuth + DiscordProvider
I feel like I might be going about my setup wrong, but just wanted to check in. I basically want a bunch of users that are purely based on Discord accounts, and then to use their data for my Discord dashboard.
Here is my prisma user schema (rest are default)
The error I am getting is
But can I disable this somehow?? I am overriding the signIn function so I presumed that would do it:
Any ideas? This setup works fine as the database has the user ID in it fine, but its just that this is now giving me that above error. Plus, is this the best way to handle this? Seems a bit convuluted.
Thanks!
13 Replies
You’re not actually overriding sign in sign in is just a callback function that runs when the sign in function is called, instead you need to override it on the adapter
Create an adapter | NextAuth.js
Using a custom adapter you can connect to any database back-end or even several different databases. Official adapters created and maintained by our community can be found in the adapters packages. Feel free to add a custom adapter from your project to the repository, or even become a maintainer of a certain adapter. Custom adapters can still be...
Ahh I see
That makes sense because I knew the invocation had to come from somewhere that wasn’t me 😂
Here’s my custom adapter if you need a reference:
https://github.com/AnswerOverflow/AnswerOverflow/blob/main/packages/auth/src/adapter.ts
GitHub
AnswerOverflow/packages/auth/src/adapter.ts at main · AnswerOverflo...
Indexing Discord Help Channel Questions into Google - AnswerOverflow/AnswerOverflow
What’s better practise though for only a single OAuth account? Do people normally modify the User table or would they just find the Account entry every session callback?
Thanks for this!
This seems like the best way to do it by the looks of it for full control
I kept the normal NextAuth model but added on a Discord account reference to the account table
I think, it’s been a little while
Yeah all the adapters are open source so it’s pretty easy to just copy paste and modify them
I’ll take a look through your implementation and see how it works compared to my use case
Cool bot by the way! I like the concept of the website too
You can also only override a portion of it by doing:
{
…oldAdapter
new function:() => {}
}
Thanks!
Ahhh true
Say hi to the website visitors 👋
🫡
Nice that it’s open source too 🙂
I’ll give that a test out then and see where I get with it
Thanks for those resources!
Actually one (small) other question, all the data inputs you’re taking in the adapter, where are they defined?
Is that in one of the callbacks of the Provider or?
They’re defined in the Adapter type from next auth
Ah so they’re auto-typed
Nice