The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
wip
Kiran Kc332f9fef161
diff --git a/apps/web/app/api/oauth/token/exchange-code-for-token.ts b/apps/web/app/api/oauth/token/exchange-code-for-token.tsindex 900040ae40..6e5909636e 100644--- a/apps/web/app/api/oauth/token/exchange-code-for-token.ts+++ b/apps/web/app/api/oauth/token/exchange-code-for-token.ts@@ -50,6 +50,7 @@ export const exchangeAuthCodeForToken = async (clientId,},select: {+ integrationId: true,pkce: true,hashedClientSecret: true,},@@ -157,8 +158,6 @@ export const exchangeAuthCodeForToken = async (},});- const { userId, projectId, scopes } = accessCode;-const accessToken = createToken({length: OAUTH_CONFIG.ACCESS_TOKEN_LENGTH,prefix: OAUTH_CONFIG.ACCESS_TOKEN_PREFIX,@@ -172,20 +171,23 @@ export const exchangeAuthCodeForToken = async (Date.now() + OAUTH_CONFIG.ACCESS_TOKEN_LIFETIME * 1000,);- // Add to authorized apps+ const { userId, projectId, scopes } = accessCode;+ const { integrationId } = app;++ // Install the app// We only support one token per client per user per workspace at a time- const installation = await prisma.oAuthAuthorizedApp.upsert({+ const installation = await prisma.installedIntegration.upsert({create: {userId,projectId,- clientId,+ integrationId: integrationId!,},update: {},where: {- userId_projectId_clientId: {- clientId,+ userId_integrationId_projectId: {userId,projectId,+ integrationId: integrationId!,},},});diff --git a/apps/web/prisma/schema/oauth.prisma b/apps/web/prisma/schema/oauth.prismaindex ad83590109..01924ee46d 100644--- a/apps/web/prisma/schema/oauth.prisma+++ b/apps/web/prisma/schema/oauth.prisma@@ -2,22 +2,22 @@ model OAuthApp {// To be removed// name String// slug String @unique- // description String?- // readme String? @db.LongText+ description String?+ readme String? @db.LongText// developer String// website String- // logo String?- // screenshots Json?- userId String?- projectId String- // verified Boolean @default(false)- // createdAt DateTime @default(now())+ logo String?+ screenshots Json?+ userId String?+ projectId String+ verified Boolean @default(false)+ createdAt DateTime @default(now())// updatedAt DateTime @updatedAt- user User? @relation(fields: [userId], references: [id], onDelete: SetNull)- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ user User? @relation(fields: [userId], references: [id], onDelete: SetNull)+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)id String @id @default(cuid())- integrationId String? @unique // Maybe remove the optional mark after migration @unique+ integrationId String? @unique // Remove the optional after completing the migrationclientId String @uniquehashedClientSecret StringpartialClientSecret String