Skip to content

Multi-provider authentication for a same account #165

Answered by sergiodxa
binajmen asked this question in Q&A
Discussion options

You must be logged in to vote

This is a really interesting questions, and the answer can depend on how you build your data. I'll mention two options.

The first option is the simples, create your User model

enum Role {
  user
  manager
  admin
}

model User {
  id             String           @id @default(uuid()) @db.Uuid
  email          String           @unique
  password       String
  role           Role
}

Then use the email to find the user in every strategy, in the FormStrategy you will also check the password, but on Google/Facebook/etc you can find the user using the email.


Another option, is to keep the providers the user used

model Identity {
  id            String  @id @default(uuid())
  provider      String

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by binajmen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants