Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

rever the schema changes

Kiran K5f2b7ff61bb4
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.ts
index 6e5909636e..bdf1958736 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
@@ -158,6 +158,8 @@ export const exchangeAuthCodeForToken = async (
},
});
+ const { userId, projectId, scopes } = accessCode;
+
const accessToken = createToken({
length: OAUTH_CONFIG.ACCESS_TOKEN_LENGTH,
prefix: OAUTH_CONFIG.ACCESS_TOKEN_PREFIX,
@@ -171,23 +173,20 @@ export const exchangeAuthCodeForToken = async (
Date.now() + OAUTH_CONFIG.ACCESS_TOKEN_LIFETIME * 1000,
);
- 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.installedIntegration.upsert({
+ const installation = await prisma.oAuthAuthorizedApp.upsert({
create: {
userId,
projectId,
- integrationId: integrationId!,
+ clientId,
},
update: {},
where: {
- userId_integrationId_projectId: {
+ userId_projectId_clientId: {
userId,
projectId,
- integrationId: integrationId!,
+ clientId,
},
},
});
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page.tsx
index 71faee525e..022906d8cc 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page.tsx
@@ -18,14 +18,14 @@ export default async function IntegrationsPage() {
}
const Integrations = async () => {
- const integrations = await prisma.integration.findMany({
+ const integrations = await prisma.oAuthApp.findMany({
where: {
verified: true,
},
include: {
_count: {
select: {
- installations: true,
+ authorizedApps: true,
},
},
},
@@ -35,7 +35,7 @@ const Integrations = async () => {
<IntegrationsPageClient
integrations={integrations.map((integration) => ({
...integration,
- installations: integration._count.installations,
+ installations: integration._count.authorizedApps,
}))}
/>
);
diff --git a/apps/web/prisma/schema/oauth.prisma b/apps/web/prisma/schema/oauth.prisma
index 01924ee46d..54d1e6a762 100644
--- a/apps/web/prisma/schema/oauth.prisma
+++ b/apps/web/prisma/schema/oauth.prisma
@@ -1,18 +1,18 @@
model OAuthApp {
// To be removed
- // name String
- // slug String @unique
+ name String
+ slug String @unique
description String?
readme String? @db.LongText
- // developer String
- // website String
+ developer String
+ website String
logo String?
screenshots Json?
userId String?
projectId String
verified Boolean @default(false)
createdAt DateTime @default(now())
- // updatedAt DateTime @updatedAt
+ updatedAt DateTime @updatedAt
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)