fix: pass organization id

This commit is contained in:
Oleg Proskurin 2025-10-04 00:13:02 +07:00
parent bd0cf2d70a
commit c6f359c126
3 changed files with 5 additions and 1 deletions

View File

@ -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

View File

@ -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,

View File

@ -69,6 +69,7 @@ export async function createProjectApiKey(
body: JSON.stringify({
type: 'project',
projectId: project.id,
organizationId: organization.id,
name: `${orgName} - ${projectName}`,
}),
});