feat: add hashedKey to apiKey and lastUsedAt datetime to keep track of usage of keys and makiung them securely stored in db

pull/2277/head
Agusti Fernandez Pardo 2022-04-04 23:56:42 +02:00
parent a3471abcf9
commit e6b2ff46ed
1 changed files with 8 additions and 6 deletions

View File

@ -366,10 +366,12 @@ model Webhook {
}
model ApiKey {
id String @id @unique @default(cuid())
userId Int?
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
expiresAt DateTime @default(dbgenerated("NOW() + interval '30 day'"))
note String?
id String @id @unique @default(cuid())
userId Int
note String?
createdAt DateTime @default(now())
expiresAt DateTime @default(dbgenerated("NOW() + interval '30 day'"))
lastUsedAt DateTime @default(now())
hashedKey String @unique()
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
}