Implement License Key API
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "LicenseKey" (
|
||||
"id" TEXT NOT NULL,
|
||||
"key" TEXT NOT NULL,
|
||||
"active" BOOLEAN NOT NULL,
|
||||
"level" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "LicenseKey_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "LicenseKey" ADD CONSTRAINT "LicenseKey_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
+15
-5
@@ -14,18 +14,19 @@ datasource db {
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id
|
||||
id String @id
|
||||
name String
|
||||
email String
|
||||
emailVerified Boolean @default(false)
|
||||
emailVerified Boolean @default(false)
|
||||
image String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
roleId Int?
|
||||
role UserRole? @relation(fields: [roleId], references: [id])
|
||||
role UserRole? @relation(fields: [roleId], references: [id])
|
||||
sessions Session[]
|
||||
accounts Account[]
|
||||
profile Profile?
|
||||
licenseKeys LicenseKey[]
|
||||
|
||||
@@unique([email])
|
||||
@@map("user")
|
||||
@@ -131,3 +132,12 @@ model AffirmationCategory {
|
||||
name String @unique
|
||||
affirmations Affirmation[]
|
||||
}
|
||||
|
||||
model LicenseKey {
|
||||
id String @id @default(uuid())
|
||||
key String
|
||||
active Boolean
|
||||
level String
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
}
|
||||
|
||||
@@ -67,3 +67,8 @@ export type SolfeggioFrequency = Prisma.SolfeggioFrequencyModel
|
||||
*
|
||||
*/
|
||||
export type AffirmationCategory = Prisma.AffirmationCategoryModel
|
||||
/**
|
||||
* Model LicenseKey
|
||||
*
|
||||
*/
|
||||
export type LicenseKey = Prisma.LicenseKeyModel
|
||||
|
||||
@@ -89,3 +89,8 @@ export type SolfeggioFrequency = Prisma.SolfeggioFrequencyModel
|
||||
*
|
||||
*/
|
||||
export type AffirmationCategory = Prisma.AffirmationCategoryModel
|
||||
/**
|
||||
* Model LicenseKey
|
||||
*
|
||||
*/
|
||||
export type LicenseKey = Prisma.LicenseKeyModel
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -393,7 +393,8 @@ export const ModelName = {
|
||||
Verification: 'Verification',
|
||||
Affirmation: 'Affirmation',
|
||||
SolfeggioFrequency: 'SolfeggioFrequency',
|
||||
AffirmationCategory: 'AffirmationCategory'
|
||||
AffirmationCategory: 'AffirmationCategory',
|
||||
LicenseKey: 'LicenseKey'
|
||||
} as const
|
||||
|
||||
export type ModelName = (typeof ModelName)[keyof typeof ModelName]
|
||||
@@ -409,7 +410,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
||||
omit: GlobalOmitOptions
|
||||
}
|
||||
meta: {
|
||||
modelProps: "user" | "profile" | "address" | "session" | "account" | "userRole" | "verification" | "affirmation" | "solfeggioFrequency" | "affirmationCategory"
|
||||
modelProps: "user" | "profile" | "address" | "session" | "account" | "userRole" | "verification" | "affirmation" | "solfeggioFrequency" | "affirmationCategory" | "licenseKey"
|
||||
txIsolationLevel: TransactionIsolationLevel
|
||||
}
|
||||
model: {
|
||||
@@ -1153,6 +1154,80 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
||||
}
|
||||
}
|
||||
}
|
||||
LicenseKey: {
|
||||
payload: Prisma.$LicenseKeyPayload<ExtArgs>
|
||||
fields: Prisma.LicenseKeyFieldRefs
|
||||
operations: {
|
||||
findUnique: {
|
||||
args: Prisma.LicenseKeyFindUniqueArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$LicenseKeyPayload> | null
|
||||
}
|
||||
findUniqueOrThrow: {
|
||||
args: Prisma.LicenseKeyFindUniqueOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$LicenseKeyPayload>
|
||||
}
|
||||
findFirst: {
|
||||
args: Prisma.LicenseKeyFindFirstArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$LicenseKeyPayload> | null
|
||||
}
|
||||
findFirstOrThrow: {
|
||||
args: Prisma.LicenseKeyFindFirstOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$LicenseKeyPayload>
|
||||
}
|
||||
findMany: {
|
||||
args: Prisma.LicenseKeyFindManyArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$LicenseKeyPayload>[]
|
||||
}
|
||||
create: {
|
||||
args: Prisma.LicenseKeyCreateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$LicenseKeyPayload>
|
||||
}
|
||||
createMany: {
|
||||
args: Prisma.LicenseKeyCreateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
createManyAndReturn: {
|
||||
args: Prisma.LicenseKeyCreateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$LicenseKeyPayload>[]
|
||||
}
|
||||
delete: {
|
||||
args: Prisma.LicenseKeyDeleteArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$LicenseKeyPayload>
|
||||
}
|
||||
update: {
|
||||
args: Prisma.LicenseKeyUpdateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$LicenseKeyPayload>
|
||||
}
|
||||
deleteMany: {
|
||||
args: Prisma.LicenseKeyDeleteManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateMany: {
|
||||
args: Prisma.LicenseKeyUpdateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateManyAndReturn: {
|
||||
args: Prisma.LicenseKeyUpdateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$LicenseKeyPayload>[]
|
||||
}
|
||||
upsert: {
|
||||
args: Prisma.LicenseKeyUpsertArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$LicenseKeyPayload>
|
||||
}
|
||||
aggregate: {
|
||||
args: Prisma.LicenseKeyAggregateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.AggregateLicenseKey>
|
||||
}
|
||||
groupBy: {
|
||||
args: Prisma.LicenseKeyGroupByArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.LicenseKeyGroupByOutputType>[]
|
||||
}
|
||||
count: {
|
||||
args: Prisma.LicenseKeyCountArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.LicenseKeyCountAggregateOutputType> | number
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} & {
|
||||
other: {
|
||||
@@ -1312,6 +1387,17 @@ export const AffirmationCategoryScalarFieldEnum = {
|
||||
export type AffirmationCategoryScalarFieldEnum = (typeof AffirmationCategoryScalarFieldEnum)[keyof typeof AffirmationCategoryScalarFieldEnum]
|
||||
|
||||
|
||||
export const LicenseKeyScalarFieldEnum = {
|
||||
id: 'id',
|
||||
key: 'key',
|
||||
active: 'active',
|
||||
level: 'level',
|
||||
userId: 'userId'
|
||||
} as const
|
||||
|
||||
export type LicenseKeyScalarFieldEnum = (typeof LicenseKeyScalarFieldEnum)[keyof typeof LicenseKeyScalarFieldEnum]
|
||||
|
||||
|
||||
export const SortOrder = {
|
||||
asc: 'asc',
|
||||
desc: 'desc'
|
||||
@@ -1509,6 +1595,7 @@ export type GlobalOmitConfig = {
|
||||
affirmation?: Prisma.AffirmationOmit
|
||||
solfeggioFrequency?: Prisma.SolfeggioFrequencyOmit
|
||||
affirmationCategory?: Prisma.AffirmationCategoryOmit
|
||||
licenseKey?: Prisma.LicenseKeyOmit
|
||||
}
|
||||
|
||||
/* Types for Logging */
|
||||
|
||||
@@ -60,7 +60,8 @@ export const ModelName = {
|
||||
Verification: 'Verification',
|
||||
Affirmation: 'Affirmation',
|
||||
SolfeggioFrequency: 'SolfeggioFrequency',
|
||||
AffirmationCategory: 'AffirmationCategory'
|
||||
AffirmationCategory: 'AffirmationCategory',
|
||||
LicenseKey: 'LicenseKey'
|
||||
} as const
|
||||
|
||||
export type ModelName = (typeof ModelName)[keyof typeof ModelName]
|
||||
@@ -199,6 +200,17 @@ export const AffirmationCategoryScalarFieldEnum = {
|
||||
export type AffirmationCategoryScalarFieldEnum = (typeof AffirmationCategoryScalarFieldEnum)[keyof typeof AffirmationCategoryScalarFieldEnum]
|
||||
|
||||
|
||||
export const LicenseKeyScalarFieldEnum = {
|
||||
id: 'id',
|
||||
key: 'key',
|
||||
active: 'active',
|
||||
level: 'level',
|
||||
userId: 'userId'
|
||||
} as const
|
||||
|
||||
export type LicenseKeyScalarFieldEnum = (typeof LicenseKeyScalarFieldEnum)[keyof typeof LicenseKeyScalarFieldEnum]
|
||||
|
||||
|
||||
export const SortOrder = {
|
||||
asc: 'asc',
|
||||
desc: 'desc'
|
||||
|
||||
@@ -18,4 +18,5 @@ export type * from './models/Verification.ts'
|
||||
export type * from './models/Affirmation.ts'
|
||||
export type * from './models/SolfeggioFrequency.ts'
|
||||
export type * from './models/AffirmationCategory.ts'
|
||||
export type * from './models/LicenseKey.ts'
|
||||
export type * from './commonInputTypes.ts'
|
||||
File diff suppressed because it is too large
Load Diff
@@ -244,6 +244,7 @@ export type UserWhereInput = {
|
||||
sessions?: Prisma.SessionListRelationFilter
|
||||
accounts?: Prisma.AccountListRelationFilter
|
||||
profile?: Prisma.XOR<Prisma.ProfileNullableScalarRelationFilter, Prisma.ProfileWhereInput> | null
|
||||
licenseKeys?: Prisma.LicenseKeyListRelationFilter
|
||||
}
|
||||
|
||||
export type UserOrderByWithRelationInput = {
|
||||
@@ -259,6 +260,7 @@ export type UserOrderByWithRelationInput = {
|
||||
sessions?: Prisma.SessionOrderByRelationAggregateInput
|
||||
accounts?: Prisma.AccountOrderByRelationAggregateInput
|
||||
profile?: Prisma.ProfileOrderByWithRelationInput
|
||||
licenseKeys?: Prisma.LicenseKeyOrderByRelationAggregateInput
|
||||
}
|
||||
|
||||
export type UserWhereUniqueInput = Prisma.AtLeast<{
|
||||
@@ -277,6 +279,7 @@ export type UserWhereUniqueInput = Prisma.AtLeast<{
|
||||
sessions?: Prisma.SessionListRelationFilter
|
||||
accounts?: Prisma.AccountListRelationFilter
|
||||
profile?: Prisma.XOR<Prisma.ProfileNullableScalarRelationFilter, Prisma.ProfileWhereInput> | null
|
||||
licenseKeys?: Prisma.LicenseKeyListRelationFilter
|
||||
}, "id" | "email">
|
||||
|
||||
export type UserOrderByWithAggregationInput = {
|
||||
@@ -321,6 +324,7 @@ export type UserCreateInput = {
|
||||
sessions?: Prisma.SessionCreateNestedManyWithoutUserInput
|
||||
accounts?: Prisma.AccountCreateNestedManyWithoutUserInput
|
||||
profile?: Prisma.ProfileCreateNestedOneWithoutUserInput
|
||||
licenseKeys?: Prisma.LicenseKeyCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateInput = {
|
||||
@@ -335,6 +339,7 @@ export type UserUncheckedCreateInput = {
|
||||
sessions?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput
|
||||
accounts?: Prisma.AccountUncheckedCreateNestedManyWithoutUserInput
|
||||
profile?: Prisma.ProfileUncheckedCreateNestedOneWithoutUserInput
|
||||
licenseKeys?: Prisma.LicenseKeyUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUpdateInput = {
|
||||
@@ -349,6 +354,7 @@ export type UserUpdateInput = {
|
||||
sessions?: Prisma.SessionUpdateManyWithoutUserNestedInput
|
||||
accounts?: Prisma.AccountUpdateManyWithoutUserNestedInput
|
||||
profile?: Prisma.ProfileUpdateOneWithoutUserNestedInput
|
||||
licenseKeys?: Prisma.LicenseKeyUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateInput = {
|
||||
@@ -363,6 +369,7 @@ export type UserUncheckedUpdateInput = {
|
||||
sessions?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput
|
||||
accounts?: Prisma.AccountUncheckedUpdateManyWithoutUserNestedInput
|
||||
profile?: Prisma.ProfileUncheckedUpdateOneWithoutUserNestedInput
|
||||
licenseKeys?: Prisma.LicenseKeyUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateManyInput = {
|
||||
@@ -561,6 +568,20 @@ export type UserUncheckedUpdateManyWithoutRoleNestedInput = {
|
||||
deleteMany?: Prisma.UserScalarWhereInput | Prisma.UserScalarWhereInput[]
|
||||
}
|
||||
|
||||
export type UserCreateNestedOneWithoutLicenseKeysInput = {
|
||||
create?: Prisma.XOR<Prisma.UserCreateWithoutLicenseKeysInput, Prisma.UserUncheckedCreateWithoutLicenseKeysInput>
|
||||
connectOrCreate?: Prisma.UserCreateOrConnectWithoutLicenseKeysInput
|
||||
connect?: Prisma.UserWhereUniqueInput
|
||||
}
|
||||
|
||||
export type UserUpdateOneRequiredWithoutLicenseKeysNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.UserCreateWithoutLicenseKeysInput, Prisma.UserUncheckedCreateWithoutLicenseKeysInput>
|
||||
connectOrCreate?: Prisma.UserCreateOrConnectWithoutLicenseKeysInput
|
||||
upsert?: Prisma.UserUpsertWithoutLicenseKeysInput
|
||||
connect?: Prisma.UserWhereUniqueInput
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.UserUpdateToOneWithWhereWithoutLicenseKeysInput, Prisma.UserUpdateWithoutLicenseKeysInput>, Prisma.UserUncheckedUpdateWithoutLicenseKeysInput>
|
||||
}
|
||||
|
||||
export type UserCreateWithoutProfileInput = {
|
||||
id: string
|
||||
name: string
|
||||
@@ -572,6 +593,7 @@ export type UserCreateWithoutProfileInput = {
|
||||
role?: Prisma.UserRoleCreateNestedOneWithoutUsersInput
|
||||
sessions?: Prisma.SessionCreateNestedManyWithoutUserInput
|
||||
accounts?: Prisma.AccountCreateNestedManyWithoutUserInput
|
||||
licenseKeys?: Prisma.LicenseKeyCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutProfileInput = {
|
||||
@@ -585,6 +607,7 @@ export type UserUncheckedCreateWithoutProfileInput = {
|
||||
roleId?: number | null
|
||||
sessions?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput
|
||||
accounts?: Prisma.AccountUncheckedCreateNestedManyWithoutUserInput
|
||||
licenseKeys?: Prisma.LicenseKeyUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutProfileInput = {
|
||||
@@ -614,6 +637,7 @@ export type UserUpdateWithoutProfileInput = {
|
||||
role?: Prisma.UserRoleUpdateOneWithoutUsersNestedInput
|
||||
sessions?: Prisma.SessionUpdateManyWithoutUserNestedInput
|
||||
accounts?: Prisma.AccountUpdateManyWithoutUserNestedInput
|
||||
licenseKeys?: Prisma.LicenseKeyUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutProfileInput = {
|
||||
@@ -627,6 +651,7 @@ export type UserUncheckedUpdateWithoutProfileInput = {
|
||||
roleId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null
|
||||
sessions?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput
|
||||
accounts?: Prisma.AccountUncheckedUpdateManyWithoutUserNestedInput
|
||||
licenseKeys?: Prisma.LicenseKeyUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutSessionsInput = {
|
||||
@@ -640,6 +665,7 @@ export type UserCreateWithoutSessionsInput = {
|
||||
role?: Prisma.UserRoleCreateNestedOneWithoutUsersInput
|
||||
accounts?: Prisma.AccountCreateNestedManyWithoutUserInput
|
||||
profile?: Prisma.ProfileCreateNestedOneWithoutUserInput
|
||||
licenseKeys?: Prisma.LicenseKeyCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutSessionsInput = {
|
||||
@@ -653,6 +679,7 @@ export type UserUncheckedCreateWithoutSessionsInput = {
|
||||
roleId?: number | null
|
||||
accounts?: Prisma.AccountUncheckedCreateNestedManyWithoutUserInput
|
||||
profile?: Prisma.ProfileUncheckedCreateNestedOneWithoutUserInput
|
||||
licenseKeys?: Prisma.LicenseKeyUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutSessionsInput = {
|
||||
@@ -682,6 +709,7 @@ export type UserUpdateWithoutSessionsInput = {
|
||||
role?: Prisma.UserRoleUpdateOneWithoutUsersNestedInput
|
||||
accounts?: Prisma.AccountUpdateManyWithoutUserNestedInput
|
||||
profile?: Prisma.ProfileUpdateOneWithoutUserNestedInput
|
||||
licenseKeys?: Prisma.LicenseKeyUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutSessionsInput = {
|
||||
@@ -695,6 +723,7 @@ export type UserUncheckedUpdateWithoutSessionsInput = {
|
||||
roleId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null
|
||||
accounts?: Prisma.AccountUncheckedUpdateManyWithoutUserNestedInput
|
||||
profile?: Prisma.ProfileUncheckedUpdateOneWithoutUserNestedInput
|
||||
licenseKeys?: Prisma.LicenseKeyUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutAccountsInput = {
|
||||
@@ -708,6 +737,7 @@ export type UserCreateWithoutAccountsInput = {
|
||||
role?: Prisma.UserRoleCreateNestedOneWithoutUsersInput
|
||||
sessions?: Prisma.SessionCreateNestedManyWithoutUserInput
|
||||
profile?: Prisma.ProfileCreateNestedOneWithoutUserInput
|
||||
licenseKeys?: Prisma.LicenseKeyCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutAccountsInput = {
|
||||
@@ -721,6 +751,7 @@ export type UserUncheckedCreateWithoutAccountsInput = {
|
||||
roleId?: number | null
|
||||
sessions?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput
|
||||
profile?: Prisma.ProfileUncheckedCreateNestedOneWithoutUserInput
|
||||
licenseKeys?: Prisma.LicenseKeyUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutAccountsInput = {
|
||||
@@ -750,6 +781,7 @@ export type UserUpdateWithoutAccountsInput = {
|
||||
role?: Prisma.UserRoleUpdateOneWithoutUsersNestedInput
|
||||
sessions?: Prisma.SessionUpdateManyWithoutUserNestedInput
|
||||
profile?: Prisma.ProfileUpdateOneWithoutUserNestedInput
|
||||
licenseKeys?: Prisma.LicenseKeyUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutAccountsInput = {
|
||||
@@ -763,6 +795,7 @@ export type UserUncheckedUpdateWithoutAccountsInput = {
|
||||
roleId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null
|
||||
sessions?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput
|
||||
profile?: Prisma.ProfileUncheckedUpdateOneWithoutUserNestedInput
|
||||
licenseKeys?: Prisma.LicenseKeyUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutRoleInput = {
|
||||
@@ -776,6 +809,7 @@ export type UserCreateWithoutRoleInput = {
|
||||
sessions?: Prisma.SessionCreateNestedManyWithoutUserInput
|
||||
accounts?: Prisma.AccountCreateNestedManyWithoutUserInput
|
||||
profile?: Prisma.ProfileCreateNestedOneWithoutUserInput
|
||||
licenseKeys?: Prisma.LicenseKeyCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutRoleInput = {
|
||||
@@ -789,6 +823,7 @@ export type UserUncheckedCreateWithoutRoleInput = {
|
||||
sessions?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput
|
||||
accounts?: Prisma.AccountUncheckedCreateNestedManyWithoutUserInput
|
||||
profile?: Prisma.ProfileUncheckedCreateNestedOneWithoutUserInput
|
||||
licenseKeys?: Prisma.LicenseKeyUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutRoleInput = {
|
||||
@@ -831,6 +866,78 @@ export type UserScalarWhereInput = {
|
||||
roleId?: Prisma.IntNullableFilter<"User"> | number | null
|
||||
}
|
||||
|
||||
export type UserCreateWithoutLicenseKeysInput = {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
emailVerified?: boolean
|
||||
image?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
role?: Prisma.UserRoleCreateNestedOneWithoutUsersInput
|
||||
sessions?: Prisma.SessionCreateNestedManyWithoutUserInput
|
||||
accounts?: Prisma.AccountCreateNestedManyWithoutUserInput
|
||||
profile?: Prisma.ProfileCreateNestedOneWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutLicenseKeysInput = {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
emailVerified?: boolean
|
||||
image?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
roleId?: number | null
|
||||
sessions?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput
|
||||
accounts?: Prisma.AccountUncheckedCreateNestedManyWithoutUserInput
|
||||
profile?: Prisma.ProfileUncheckedCreateNestedOneWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutLicenseKeysInput = {
|
||||
where: Prisma.UserWhereUniqueInput
|
||||
create: Prisma.XOR<Prisma.UserCreateWithoutLicenseKeysInput, Prisma.UserUncheckedCreateWithoutLicenseKeysInput>
|
||||
}
|
||||
|
||||
export type UserUpsertWithoutLicenseKeysInput = {
|
||||
update: Prisma.XOR<Prisma.UserUpdateWithoutLicenseKeysInput, Prisma.UserUncheckedUpdateWithoutLicenseKeysInput>
|
||||
create: Prisma.XOR<Prisma.UserCreateWithoutLicenseKeysInput, Prisma.UserUncheckedCreateWithoutLicenseKeysInput>
|
||||
where?: Prisma.UserWhereInput
|
||||
}
|
||||
|
||||
export type UserUpdateToOneWithWhereWithoutLicenseKeysInput = {
|
||||
where?: Prisma.UserWhereInput
|
||||
data: Prisma.XOR<Prisma.UserUpdateWithoutLicenseKeysInput, Prisma.UserUncheckedUpdateWithoutLicenseKeysInput>
|
||||
}
|
||||
|
||||
export type UserUpdateWithoutLicenseKeysInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
email?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
emailVerified?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
image?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
role?: Prisma.UserRoleUpdateOneWithoutUsersNestedInput
|
||||
sessions?: Prisma.SessionUpdateManyWithoutUserNestedInput
|
||||
accounts?: Prisma.AccountUpdateManyWithoutUserNestedInput
|
||||
profile?: Prisma.ProfileUpdateOneWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutLicenseKeysInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
email?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
emailVerified?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
image?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
roleId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null
|
||||
sessions?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput
|
||||
accounts?: Prisma.AccountUncheckedUpdateManyWithoutUserNestedInput
|
||||
profile?: Prisma.ProfileUncheckedUpdateOneWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateManyRoleInput = {
|
||||
id: string
|
||||
name: string
|
||||
@@ -852,6 +959,7 @@ export type UserUpdateWithoutRoleInput = {
|
||||
sessions?: Prisma.SessionUpdateManyWithoutUserNestedInput
|
||||
accounts?: Prisma.AccountUpdateManyWithoutUserNestedInput
|
||||
profile?: Prisma.ProfileUpdateOneWithoutUserNestedInput
|
||||
licenseKeys?: Prisma.LicenseKeyUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutRoleInput = {
|
||||
@@ -865,6 +973,7 @@ export type UserUncheckedUpdateWithoutRoleInput = {
|
||||
sessions?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput
|
||||
accounts?: Prisma.AccountUncheckedUpdateManyWithoutUserNestedInput
|
||||
profile?: Prisma.ProfileUncheckedUpdateOneWithoutUserNestedInput
|
||||
licenseKeys?: Prisma.LicenseKeyUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateManyWithoutRoleInput = {
|
||||
@@ -885,11 +994,13 @@ export type UserUncheckedUpdateManyWithoutRoleInput = {
|
||||
export type UserCountOutputType = {
|
||||
sessions: number
|
||||
accounts: number
|
||||
licenseKeys: number
|
||||
}
|
||||
|
||||
export type UserCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
sessions?: boolean | UserCountOutputTypeCountSessionsArgs
|
||||
accounts?: boolean | UserCountOutputTypeCountAccountsArgs
|
||||
licenseKeys?: boolean | UserCountOutputTypeCountLicenseKeysArgs
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -916,6 +1027,13 @@ export type UserCountOutputTypeCountAccountsArgs<ExtArgs extends runtime.Types.E
|
||||
where?: Prisma.AccountWhereInput
|
||||
}
|
||||
|
||||
/**
|
||||
* UserCountOutputType without action
|
||||
*/
|
||||
export type UserCountOutputTypeCountLicenseKeysArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
where?: Prisma.LicenseKeyWhereInput
|
||||
}
|
||||
|
||||
|
||||
export type UserSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
||||
id?: boolean
|
||||
@@ -930,6 +1048,7 @@ export type UserSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = r
|
||||
sessions?: boolean | Prisma.User$sessionsArgs<ExtArgs>
|
||||
accounts?: boolean | Prisma.User$accountsArgs<ExtArgs>
|
||||
profile?: boolean | Prisma.User$profileArgs<ExtArgs>
|
||||
licenseKeys?: boolean | Prisma.User$licenseKeysArgs<ExtArgs>
|
||||
_count?: boolean | Prisma.UserCountOutputTypeDefaultArgs<ExtArgs>
|
||||
}, ExtArgs["result"]["user"]>
|
||||
|
||||
@@ -974,6 +1093,7 @@ export type UserInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs =
|
||||
sessions?: boolean | Prisma.User$sessionsArgs<ExtArgs>
|
||||
accounts?: boolean | Prisma.User$accountsArgs<ExtArgs>
|
||||
profile?: boolean | Prisma.User$profileArgs<ExtArgs>
|
||||
licenseKeys?: boolean | Prisma.User$licenseKeysArgs<ExtArgs>
|
||||
_count?: boolean | Prisma.UserCountOutputTypeDefaultArgs<ExtArgs>
|
||||
}
|
||||
export type UserIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
@@ -990,6 +1110,7 @@ export type $UserPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs =
|
||||
sessions: Prisma.$SessionPayload<ExtArgs>[]
|
||||
accounts: Prisma.$AccountPayload<ExtArgs>[]
|
||||
profile: Prisma.$ProfilePayload<ExtArgs> | null
|
||||
licenseKeys: Prisma.$LicenseKeyPayload<ExtArgs>[]
|
||||
}
|
||||
scalars: runtime.Types.Extensions.GetPayloadResult<{
|
||||
id: string
|
||||
@@ -1398,6 +1519,7 @@ export interface Prisma__UserClient<T, Null = never, ExtArgs extends runtime.Typ
|
||||
sessions<T extends Prisma.User$sessionsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.User$sessionsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$SessionPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
accounts<T extends Prisma.User$accountsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.User$accountsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$AccountPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
profile<T extends Prisma.User$profileArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.User$profileArgs<ExtArgs>>): Prisma.Prisma__ProfileClient<runtime.Types.Result.GetResult<Prisma.$ProfilePayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
licenseKeys<T extends Prisma.User$licenseKeysArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.User$licenseKeysArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$LicenseKeyPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
@@ -1916,6 +2038,30 @@ export type User$profileArgs<ExtArgs extends runtime.Types.Extensions.InternalAr
|
||||
where?: Prisma.ProfileWhereInput
|
||||
}
|
||||
|
||||
/**
|
||||
* User.licenseKeys
|
||||
*/
|
||||
export type User$licenseKeysArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
/**
|
||||
* Select specific fields to fetch from the LicenseKey
|
||||
*/
|
||||
select?: Prisma.LicenseKeySelect<ExtArgs> | null
|
||||
/**
|
||||
* Omit specific fields from the LicenseKey
|
||||
*/
|
||||
omit?: Prisma.LicenseKeyOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.LicenseKeyInclude<ExtArgs> | null
|
||||
where?: Prisma.LicenseKeyWhereInput
|
||||
orderBy?: Prisma.LicenseKeyOrderByWithRelationInput | Prisma.LicenseKeyOrderByWithRelationInput[]
|
||||
cursor?: Prisma.LicenseKeyWhereUniqueInput
|
||||
take?: number
|
||||
skip?: number
|
||||
distinct?: Prisma.LicenseKeyScalarFieldEnum | Prisma.LicenseKeyScalarFieldEnum[]
|
||||
}
|
||||
|
||||
/**
|
||||
* User without action
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { prisma } from '$lib/db';
|
||||
|
||||
// Get the key and email form the URL
|
||||
// First, check if the key even exists, throw error if not
|
||||
// Second, check that the email is attached to a real user, throw error
|
||||
// Third, check that the key retrieved from the database belongs to the user, throw error
|
||||
// Return response
|
||||
export const GET: RequestHandler = async ({ url }) => {
|
||||
const key = url.searchParams.get('key') ?? '';
|
||||
const email = url.searchParams.get('email') ?? '';
|
||||
if (key === '') {
|
||||
throw error(400, 'license key required');
|
||||
}
|
||||
|
||||
const storedKey = await prisma.licenseKey.findFirst({
|
||||
where: {
|
||||
key: key
|
||||
}
|
||||
});
|
||||
|
||||
if (!storedKey) {
|
||||
throw error(400, 'license key not found');
|
||||
}
|
||||
|
||||
const userAccount = await prisma.user.findUniqueOrThrow({ where: { email: email } });
|
||||
|
||||
if (!userAccount) {
|
||||
throw error(400, 'user does not exist');
|
||||
}
|
||||
|
||||
if (storedKey.userId != userAccount.id) {
|
||||
throw error(400, 'key does not belong to specified user');
|
||||
}
|
||||
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
key: storedKey.key,
|
||||
active: storedKey.active,
|
||||
level: storedKey.level
|
||||
})
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user