feat: email verification for registration (#599)

This commit is contained in:
Catalin Pit
2023-11-21 06:42:29 +02:00
committed by Mythie
parent 6c73453542
commit fbbc3b89c3
21 changed files with 1004 additions and 598 deletions

View File

@ -0,0 +1,17 @@
-- CreateTable
CREATE TABLE "VerificationToken" (
"id" SERIAL NOT NULL,
"identifier" TEXT NOT NULL,
"token" TEXT NOT NULL,
"expires" TIMESTAMP(3) NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userId" INTEGER NOT NULL,
CONSTRAINT "VerificationToken_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "VerificationToken_token_key" ON "VerificationToken"("token");
-- AddForeignKey
ALTER TABLE "VerificationToken" ADD CONSTRAINT "VerificationToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,3 @@
UPDATE "User"
SET "emailVerified" = CURRENT_TIMESTAMP
WHERE "emailVerified" IS NULL;

View File

@ -36,7 +36,8 @@ model User {
Document Document[]
Subscription Subscription?
PasswordResetToken PasswordResetToken[]
VerificationToken VerificationToken[]
@@index([email])
}
@ -49,6 +50,16 @@ model PasswordResetToken {
User User @relation(fields: [userId], references: [id])
}
model VerificationToken {
id Int @id @default(autoincrement())
identifier String
token String @unique
expires DateTime
createdAt DateTime @default(now())
userId Int
user User @relation(fields: [userId], references: [id])
}
enum SubscriptionStatus {
ACTIVE
PAST_DUE