feat: Change auth flow
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `firstName` on the `user` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `lastName` on the `user` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `middleName` on the `user` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `profilePicture` on the `user` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "user" DROP COLUMN "firstName",
|
||||
DROP COLUMN "lastName",
|
||||
DROP COLUMN "middleName",
|
||||
DROP COLUMN "profilePicture";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "UserAdditionalInformation" (
|
||||
"id" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"firstName" TEXT NOT NULL,
|
||||
"middleName" TEXT,
|
||||
"lastName" TEXT NOT NULL,
|
||||
"profilePicture" TEXT,
|
||||
"address" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "UserAdditionalInformation_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "UserAdditionalInformation_userId_key" ON "UserAdditionalInformation"("userId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "UserAdditionalInformation" ADD CONSTRAINT "UserAdditionalInformation_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `isVerified` on the `user` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `generatedOn` on the `user_otp` table. All the data in the column will be lost.
|
||||
- Added the required column `expiresAt` to the `user_otp` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- CreateEnum
|
||||
CREATE TYPE "USER_ACCOUNT_STATUS" AS ENUM ('pending', 'active', 'suspended', 'deleted');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "user" DROP COLUMN "isVerified",
|
||||
ADD COLUMN "status" "USER_ACCOUNT_STATUS" NOT NULL DEFAULT 'pending',
|
||||
ALTER COLUMN "password" DROP NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "user_otp" DROP COLUMN "generatedOn",
|
||||
ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN "expiresAt" TIMESTAMP(3) NOT NULL;
|
||||
@@ -1,30 +1,45 @@
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
firstName String
|
||||
middleName String?
|
||||
lastName String
|
||||
email String @unique
|
||||
password String
|
||||
role USER_ROLE @default(user)
|
||||
isVerified Boolean? @default(false) // TODO: Email using queue
|
||||
refreshToken String?
|
||||
profilePicture String?
|
||||
isDeleted Boolean? @default(false)
|
||||
deletedAt DateTime?
|
||||
id String @id @default(uuid())
|
||||
email String @unique
|
||||
password String?
|
||||
role USER_ROLE @default(user)
|
||||
refreshToken String?
|
||||
status USER_ACCOUNT_STATUS @default(pending)
|
||||
isDeleted Boolean? @default(false)
|
||||
deletedAt DateTime?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
organizations OrganizationUserJoinTable[]
|
||||
organizationsRequested OrganizationJoinRequest[]
|
||||
organizations OrganizationUserJoinTable[]
|
||||
organizationsRequested OrganizationJoinRequest[]
|
||||
userAdditionalInformation UserAdditionalInformation?
|
||||
|
||||
@@map("user")
|
||||
}
|
||||
|
||||
model UserAdditionalInformation {
|
||||
id String @id @default(uuid())
|
||||
userId String @unique
|
||||
firstName String
|
||||
middleName String?
|
||||
lastName String
|
||||
profilePicture String?
|
||||
address String?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model UserOTP {
|
||||
email String @unique
|
||||
otp Int
|
||||
generatedOn DateTime
|
||||
email String @unique
|
||||
otp Int
|
||||
// ExipresAt is also saved so its easier to check and also
|
||||
// run cron job to remove expired OTPs
|
||||
createdAt DateTime @default(now())
|
||||
expiresAt DateTime
|
||||
|
||||
@@map("user_otp")
|
||||
}
|
||||
@@ -33,3 +48,10 @@ enum USER_ROLE {
|
||||
superadmin
|
||||
user
|
||||
}
|
||||
|
||||
enum USER_ACCOUNT_STATUS {
|
||||
pending
|
||||
active
|
||||
suspended
|
||||
deleted
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user