Closed Geczy closed 1 year ago
How is this handled with other providers which allow multiple users with one email? Or is this the first of its kind? If it is indeed the first of its kind might be worth having a discussion how to address it moving forward. Can see a few scenarios:
We could also make the above a configuration setting when defining the provider
I should mention, email addresses are optional on Twitch. i've had users sign up with an empty email address and oauth would error, so i had to make emails default nullable in the prisma schema, and non unique
this could be accounted for too with this issue?
Looking at the prisma docs it seems like a User
object can have multiple Account
objects and this is probably the functionality we want. Looking at the twitch adapter along with the twitch api docs the user ID is the unique identifier as opposed to the email. Hopefully a maintainer of the repo can give more clarity on what happens when a account can have multiple sub-accounts and can proceed from there. Happy to help on the PR side as well (if needed).
yeah i agree, just wanted to point out that currently prisma assumes emails are unique: https://github.com/nextauthjs/next-auth/blob/main/packages/adapter-prisma/prisma/schema.prisma#L13 so this will error for people wanting to use this in the future
also keep in mind, even if we have multiple Account objects for 1 User
object, how will we track username differences? the Account
object does not keep the username (name
), this is stored on User
(same for image
differences)
for this specific error maybe its my fault for having userId unique constraint on the Account schema. i see the prisma schema does not have unique on userId in Account. ill try without it and see what happens
yeah once removing the unique constraint it's working now to save multiple accounts. but the username / image does not match the new account
Currently, we assume that emails are the same for all accounts that are connected to a single user. Actually, the author of next-auth
assumed that multiple accounts with the same e-mail address might have been a mistake by the user, so the design heavily relies on the fact that e-mails can identify single users:
As such, this is currently expected behavior, so I'll convert this to a feature request for now, so the discussion can go on there.
Adapter type
@next-auth/prisma-adapter
Environment
https://github.com/dotabod/frontend/blob/master/package.json
Reproduction URL
https://github.com/dotabod/frontend/blob/master/prisma/schema.prisma
Describe the issue
as you can see, twitch allows multiple users with the same email address. so prisma adapter his to be updated to allow multiple linked accounts with same email
linkAccount: (data) => p.account.create({ data }),
How to reproduce
create two twitch accounts with same email address
sign in to your prisma twitch provider website with both accounts
only the first account will be created, the second one will be errored
Expected behavior
allow both accounts to be logged in with separate user ids? not sure if it shoudl link them or make new acts
tried
allowDangerousEmailAccountLinking: true
but did not change anything except bypass the first issue of this:error=OAuthAccountNotLinked