feat: refactoring auth & add email password login (#318)

* feat: wip

* fix: issues

* feat: clean controllers and services

* fix: test

* Fix auth

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Jérémy M
2023-06-17 13:42:02 +02:00
committed by GitHub
parent d13ceb98fa
commit 299ca293a8
215 changed files with 1668 additions and 680 deletions

View File

@ -0,0 +1,11 @@
/*
Warnings:
- You are about to drop the column `refreshToken` on the `refresh_tokens` table. All the data in the column will be lost.
- Added the required column `expiresAt` to the `refresh_tokens` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "refresh_tokens" DROP COLUMN "refreshToken",
ADD COLUMN "expiresAt" TIMESTAMP(3) NOT NULL,
ADD COLUMN "isRevoked" BOOLEAN NOT NULL DEFAULT false;

View File

@ -113,7 +113,7 @@ generator nestgraphql {
}
model User {
id String @id
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
@ -124,6 +124,7 @@ model User {
avatarUrl String?
locale String
phoneNumber String?
/// @TypeGraphQL.omit(input: true, output: true)
passwordHash String?
emailVerified Boolean @default(false)
metadata Json?
@ -139,7 +140,7 @@ model User {
/// @TypeGraphQL.omit(input: true)
model Workspace {
id String @id
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
@ -159,7 +160,7 @@ model Workspace {
}
model WorkspaceMember {
id String @id
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
@ -174,7 +175,7 @@ model WorkspaceMember {
}
model Company {
id String @id
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
@ -195,7 +196,7 @@ model Company {
}
model Person {
id String @id
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
@ -216,19 +217,22 @@ model Person {
}
model RefreshToken {
id String @id
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
isRevoked Boolean @default(false)
expiresAt DateTime
deletedAt DateTime?
refreshToken String
/// @TypeGraphQL.omit(input: true, output: true)
userId String
/// @TypeGraphQL.omit(input: true, output: true)
user User @relation(fields: [userId], references: [id])
@@map("refresh_tokens")
}
model CommentThread {
id String @id
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
@ -243,7 +247,7 @@ model CommentThread {
}
model Comment {
id String @id
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
@ -266,7 +270,7 @@ enum CommentableType {
}
model CommentThreadTarget {
id String @id
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
@ -280,7 +284,7 @@ model CommentThreadTarget {
}
model Pipeline {
id String @id
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
@ -298,7 +302,7 @@ model Pipeline {
}
model PipelineStage {
id String @id
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
@ -326,7 +330,7 @@ enum PipelineProgressableType {
}
model PipelineProgress {
id String @id
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
@ -340,7 +344,7 @@ model PipelineProgress {
progressableType PipelineProgressableType
progressableId String
/// @TypeGraphQL.omit(input: true, output: true)
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])

View File

@ -1,5 +1,30 @@
import { PrismaClient } from '@prisma/client';
export const seedUsers = async (prisma: PrismaClient) => {
await prisma.user.upsert({
where: { id: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfc102' },
update: {},
create: {
id: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfc102',
displayName: 'Twenty Demo',
email: 'demo@test.com',
passwordHash:
'$2b$10$mTVxSneZmbXsf9DxTlZRA.DyRO6aCCCOTTxeDv76KuJD524ZpaaZi', // twentydemo
locale: 'en',
avatarUrl:
'https://s3-alpha-sig.figma.com/img/bbb5/4905/f0a52cc2b9aaeb0a82a360d478dae8bf?Expires=1687132800&Signature=iVBr0BADa3LHoFVGbwqO-wxC51n1o~ZyFD-w7nyTyFP4yB-Y6zFawL-igewaFf6PrlumCyMJThDLAAc-s-Cu35SBL8BjzLQ6HymzCXbrblUADMB208PnMAvc1EEUDq8TyryFjRO~GggLBk5yR0EXzZ3zenqnDEGEoQZR~TRqS~uDF-GwQB3eX~VdnuiU2iittWJkajIDmZtpN3yWtl4H630A3opQvBnVHZjXAL5YPkdh87-a-H~6FusWvvfJxfNC2ZzbrARzXofo8dUFtH7zUXGCC~eUk~hIuLbLuz024lFQOjiWq2VKyB7dQQuGFpM-OZQEV8tSfkViP8uzDLTaCg__&Key-Pair-Id=APKAQ4GOSFWCVNEHN3O4',
workspaceMember: {
connectOrCreate: {
where: {
id: 'twenty-7ef9d213-1c25-4d02-bf35-6aeccf7ea419',
},
create: {
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
},
},
},
},
});
await prisma.user.upsert({
where: { id: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfa408' },
update: {},