af07a73a07
- Added a new `LoginAttempt` model to track login attempts, including rate limiting and lockout functionality. - Introduced environment variables for configuring login rate limits and maximum failures. - Updated the authentication middleware to handle login attempts and enforce rate limits. - Enhanced the user model with indexing for username and email for improved lookup performance. - Modified the `.env.example` file to include new optional authentication settings. - Updated integration tests to cover new login attempt features and authentication state management.
80 lines
2.3 KiB
Plaintext
80 lines
2.3 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
output = "../src/generated/client"
|
|
binaryTargets = ["native", "linux-musl-arm64-openssl-3.0.x", "linux-musl-openssl-3.0.x"]
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Collection {
|
|
id String @id @default(uuid())
|
|
name String
|
|
drawings Drawing[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model Drawing {
|
|
id String @id @default(uuid())
|
|
name String
|
|
elements String // Stored as JSON string
|
|
appState String // Stored as JSON string
|
|
files String @default("{}") // Stored as JSON string
|
|
preview String? // SVG string for thumbnail
|
|
version Int @default(1)
|
|
collectionId String?
|
|
collection Collection? @relation(fields: [collectionId], references: [id])
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model Library {
|
|
id String @id @default("default") // Singleton pattern - use "default" ID
|
|
items String @default("[]") // Stored as JSON string array of library items
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
username String? @unique
|
|
email String? @unique
|
|
passwordHash String
|
|
mustResetPassword Boolean @default(false)
|
|
role String @default("USER")
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([username])
|
|
@@index([email])
|
|
}
|
|
|
|
model SystemConfig {
|
|
id String @id @default("default")
|
|
registrationEnabled Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model LoginAttempt {
|
|
id String @id @default(uuid())
|
|
identifier String
|
|
ip String
|
|
count Int @default(0)
|
|
failures Int @default(0)
|
|
resetTime DateTime
|
|
lockoutUntil DateTime?
|
|
lastAttempt DateTime @default(now())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([identifier, ip])
|
|
@@index([lastAttempt])
|
|
}
|