fix: pass organization id
This commit is contained in:
parent
bd0cf2d70a
commit
c6f359c126
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ export async function createProjectApiKey(
|
|||
body: JSON.stringify({
|
||||
type: 'project',
|
||||
projectId: project.id,
|
||||
organizationId: organization.id,
|
||||
name: `${orgName} - ${projectName}`,
|
||||
}),
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue