Is it possible to link additional (social) provide...
# help
a
Is it possible to link additional (social) providers to an existing user (email, password) when they are already logged in AND the email address isn't the same?
n
Hello @Amos! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
g
Email is used as the unique identifier, so I believe no.
n
Amos (2022-04-04)
s
just a guess at a workaround, but I'd imagine what needs to be done is that you'd need to maintain a secondary record of all of your users in your database schema which has a different unique ID. Then possibly you could have a postgres function that, on the creation of a new auth user record, checks to see if there is an existing user with the email from the social login and uses that to update a record of linked social accounts. But that would also complicate matters in that you'd have multiple records in your auth db which are all technically unique users, that all have control over a separate record in your app's database
g
Not sure how you connect the two different emails... With some still not clear side effects, you can have multiple 3rd party logins IF the email is the same currently. Not sure if the side effects are just with a email/password login in addition to 3rd party, or multiple 3rd party. But in general same email all goes to same user.
s
with two different emails I dunno, can only begin to imagine a solution to match records to a common email, such as when a user signs up with username/password and provides a gmail address, then uses gmail oauth login with that same address
g
You actually don't need a full solution with same email, Supabase auth adds them to the to app_meta_data under the same user and seems to track them in identities table. The issue comes in with additional email/pass login as pass is not used for the others.
a
Yeah if the email is the same it works perfectly, but the problem is when they aren't