Auth is one of our flagship features, it’s simple to get started and it’s free. But sometimes setting it up can be annoying, copy pasting the User
and SocialLogin
entities every time. Currently, developers are mixing their business logic (e.g. tasks
) fields with Wasp’s auth fields (e.g. password
) etc.
We don’t want the user to know details about auth implementation details. One of the most annoying details is caring about the Prisma models that are related to auth.
Developers have to define the User and SocialLogin with all of the fields
It would be cool if developers could only define their fields
User
entityWe want to keep all of the auth related data in their separate entities, we’ll name them Auth
and SocialAuthProvider
(
model Auth {
id String @id @default(uuid())
// Both email and username are here and both are optional (read more below)
email String? @unique
username String? @unique
password String?
isEmailVerified Boolean @default(false)
emailVerificationSentAt DateTime?
passwordResetSentAt DateTime?
userId String? @unique
// Connection to possible social auth providers
providers SocialAuthProvider[]
// Connection to the business logic user
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model SocialAuthProvider {
id String @id @default(uuid())
provider String
providerId String
authId String
auth Auth @relation(fields: [authId], references: [id], onDelete: Cascade)
}