From c6f359c126f073b8bf795dd32acf687b422ae706 Mon Sep 17 00:00:00 2001 From: Oleg Proskurin Date: Sat, 4 Oct 2025 00:13:02 +0700 Subject: [PATCH] fix: pass organization id --- apps/api-service/src/routes/admin/keys.ts | 3 ++- apps/api-service/src/services/ApiKeyService.ts | 2 ++ apps/landing/src/lib/actions/apiKeyActions.ts | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/api-service/src/routes/admin/keys.ts b/apps/api-service/src/routes/admin/keys.ts index cadfd89..eb91c5a 100644 --- a/apps/api-service/src/routes/admin/keys.ts +++ b/apps/api-service/src/routes/admin/keys.ts @@ -16,7 +16,7 @@ router.use(requireMasterKey); */ router.post('/', async (req, res) => { try { - const { type, projectId, name, expiresInDays } = req.body; + const { type, projectId, organizationId, name, expiresInDays } = req.body; // Validation if (!type || !['master', 'project'].includes(type)) { @@ -38,6 +38,7 @@ router.post('/', async (req, res) => { ? await apiKeyService.createMasterKey(name, req.apiKey!.id) : await apiKeyService.createProjectKey( projectId, + organizationId, name, req.apiKey!.id, expiresInDays || 90 diff --git a/apps/api-service/src/services/ApiKeyService.ts b/apps/api-service/src/services/ApiKeyService.ts index b18017a..bce5426 100644 --- a/apps/api-service/src/services/ApiKeyService.ts +++ b/apps/api-service/src/services/ApiKeyService.ts @@ -49,6 +49,7 @@ export class ApiKeyService { */ async createProjectKey( projectId: string, + organizationId?: string, name?: string, createdBy?: string, expiresInDays: number = 90 @@ -63,6 +64,7 @@ export class ApiKeyService { keyPrefix, keyType: 'project', projectId, + organizationId: organizationId || null, scopes: ['generate', 'read'], name: name || `Project Key - ${projectId}`, expiresAt, diff --git a/apps/landing/src/lib/actions/apiKeyActions.ts b/apps/landing/src/lib/actions/apiKeyActions.ts index e6db8f2..e655eb0 100644 --- a/apps/landing/src/lib/actions/apiKeyActions.ts +++ b/apps/landing/src/lib/actions/apiKeyActions.ts @@ -69,6 +69,7 @@ export async function createProjectApiKey( body: JSON.stringify({ type: 'project', projectId: project.id, + organizationId: organization.id, name: `${orgName} - ${projectName}`, }), });