mirror of
https://github.com/woodchen-ink/Q58Connect.git
synced 2025-07-18 05:51:55 +08:00
- Introduced `allowedUsers` field to Client model for granular access control - Implemented user filtering in authorization process - Updated client edit form with allowed users configuration - Enhanced dashboard and admin pages with improved user and client management - Refactored client update and delete API routes - Added form validation using Zod and react-hook-form
117 lines
2.3 KiB
Plaintext
117 lines
2.3 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
previewFeatures = ["postgresqlExtensions"]
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
directUrl = env("DATABASE_URL_UNPOOLED")
|
|
}
|
|
|
|
enum UserRole {
|
|
ADMIN
|
|
USER
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
username String @unique
|
|
email String @unique
|
|
name String?
|
|
avatarUrl String?
|
|
role UserRole @default(USER)
|
|
moderator Boolean @default(false)
|
|
groups String[]
|
|
|
|
clients Client[]
|
|
codes Code[]
|
|
accessTokens AccessToken[]
|
|
|
|
authorizations Authorization[]
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
model Client {
|
|
id String @id @default(cuid())
|
|
name String
|
|
redirectUri String
|
|
home String
|
|
logo String
|
|
description String?
|
|
enabled Boolean @default(true)
|
|
allowedUsers String[] @default([])
|
|
|
|
clientId String @unique
|
|
clientSecret String
|
|
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
authCodes Code[]
|
|
accessTokens AccessToken[]
|
|
|
|
authorizations Authorization[]
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@map("clients")
|
|
}
|
|
|
|
model Code {
|
|
id String @id @default(cuid())
|
|
code String @unique
|
|
expiresAt DateTime
|
|
deletedAt DateTime?
|
|
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
clientId String
|
|
client Client @relation(fields: [clientId], references: [id])
|
|
|
|
@@map("codes")
|
|
}
|
|
|
|
model AccessToken {
|
|
id String @id @default(cuid())
|
|
token String @unique
|
|
expiresAt DateTime
|
|
error String?
|
|
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
clientId String
|
|
client Client @relation(fields: [clientId], references: [id])
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@map("access_tokens")
|
|
}
|
|
|
|
model Authorization {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
clientId String
|
|
client Client @relation(fields: [clientId], references: [id])
|
|
|
|
scope String?
|
|
enabled Boolean @default(true)
|
|
lastUsedAt DateTime?
|
|
|
|
@@unique([userId, clientId])
|
|
@@map("authorizations")
|
|
}
|