Next-auth oauth and credentials linking
Answered
Common paper wasp posted this in #help-forum
Common paper waspOP
So let say a user signs up with an github account which has jondoe@gmail.com as his email.
Then same user signs up using jondoe@gmail.com with custom credentials.
What happens now? Are these accounts count as same accounts?
Then same user signs up using jondoe@gmail.com with custom credentials.
What happens now? Are these accounts count as same accounts?
Answered by riský
talking about the db tables: https://authjs.dev/reference/adapter/prisma#create-the-prisma-schema-from-scratch
18 Replies
@Common paper wasp So let say a user signs up with an github account which has jondoe@gmail.com as his email.
Then same user signs up using jondoe@gmail.com with custom credentials.
What happens now? Are these accounts count as same accounts?
if you have [
allowDangerousEmailAccountLinking](https://next-auth.js.org/configuration/providers/oauth#allowdangerousemailaccountlinking-option), they will link, otherwise iirc it errors@riský if you have [`allowDangerousEmailAccountLinking`](<https://next-auth.js.org/configuration/providers/oauth#allowdangerousemailaccountlinking-option>), they will link, otherwise iirc it errors
Common paper waspOP
So I only have to add this to github provider?
looks like it
but i am not fully sure now (as i was thinking about the other way arround)
but test and see 🙂
Common paper waspOP
I can not think of a way to test it actually.
how come?
like if you can't test your github account with same email, how do you test that nextjs works?
Common paper waspOP
No I meant how can I check if they are linked in my app?
uhh id asume if it links (hopefully with that config change) it would be one user and multiple accounts
Common paper waspOP
Hmm
So linking actually does nothing? Cause user still has 2 different accounts. What does linking do? If I proceed to show some data related to one of his account, the other account can get those data too?
talking about the db tables: https://authjs.dev/reference/adapter/prisma#create-the-prisma-schema-from-scratch
Answer
Common paper waspOP
Oh
@riský talking about the db tables: https://authjs.dev/reference/adapter/prisma#create-the-prisma-schema-from-scratch
Common paper waspOP
Ok i never knew i have to use db adapter. wasn't mentioned in next-auth
oh, idk how things work without, but that makes sense why you were confused
Common paper waspOP
Yep it all makes sense now
Thank you