Feature/set hashedKey of ApiKey to unique (#4103)
* Set hashedKey to unique
This commit is contained in:
parent
1be0a64417
commit
0e01674552
@ -32,7 +32,7 @@ export class ApiKeyService {
|
||||
public async getUserByApiKey(apiKey: string) {
|
||||
const hashedKey = this.hashApiKey(apiKey);
|
||||
|
||||
const { user } = await this.prismaService.apiKey.findFirst({
|
||||
const { user } = await this.prismaService.apiKey.findUnique({
|
||||
include: { user: true },
|
||||
where: { hashedKey }
|
||||
});
|
||||
|
@ -0,0 +1,5 @@
|
||||
-- DropIndex
|
||||
DROP INDEX "ApiKey_hashedKey_idx";
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ApiKey_hashedKey_key" ON "ApiKey"("hashedKey");
|
@ -79,13 +79,12 @@ model Analytics {
|
||||
|
||||
model ApiKey {
|
||||
createdAt DateTime @default(now())
|
||||
hashedKey String
|
||||
hashedKey String @unique
|
||||
id String @id @default(uuid())
|
||||
updatedAt DateTime @updatedAt
|
||||
userId String
|
||||
user User @relation(fields: [userId], onDelete: Cascade, references: [id])
|
||||
|
||||
@@index([hashedKey])
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user