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) => {
|
router.post('/', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { type, projectId, name, expiresInDays } = req.body;
|
const { type, projectId, organizationId, name, expiresInDays } = req.body;
|
||||||
|
|
||||||
// Validation
|
// Validation
|
||||||
if (!type || !['master', 'project'].includes(type)) {
|
if (!type || !['master', 'project'].includes(type)) {
|
||||||
|
|
@ -38,6 +38,7 @@ router.post('/', async (req, res) => {
|
||||||
? await apiKeyService.createMasterKey(name, req.apiKey!.id)
|
? await apiKeyService.createMasterKey(name, req.apiKey!.id)
|
||||||
: await apiKeyService.createProjectKey(
|
: await apiKeyService.createProjectKey(
|
||||||
projectId,
|
projectId,
|
||||||
|
organizationId,
|
||||||
name,
|
name,
|
||||||
req.apiKey!.id,
|
req.apiKey!.id,
|
||||||
expiresInDays || 90
|
expiresInDays || 90
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ export class ApiKeyService {
|
||||||
*/
|
*/
|
||||||
async createProjectKey(
|
async createProjectKey(
|
||||||
projectId: string,
|
projectId: string,
|
||||||
|
organizationId?: string,
|
||||||
name?: string,
|
name?: string,
|
||||||
createdBy?: string,
|
createdBy?: string,
|
||||||
expiresInDays: number = 90
|
expiresInDays: number = 90
|
||||||
|
|
@ -63,6 +64,7 @@ export class ApiKeyService {
|
||||||
keyPrefix,
|
keyPrefix,
|
||||||
keyType: 'project',
|
keyType: 'project',
|
||||||
projectId,
|
projectId,
|
||||||
|
organizationId: organizationId || null,
|
||||||
scopes: ['generate', 'read'],
|
scopes: ['generate', 'read'],
|
||||||
name: name || `Project Key - ${projectId}`,
|
name: name || `Project Key - ${projectId}`,
|
||||||
expiresAt,
|
expiresAt,
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ export async function createProjectApiKey(
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
type: 'project',
|
type: 'project',
|
||||||
projectId: project.id,
|
projectId: project.id,
|
||||||
|
organizationId: organization.id,
|
||||||
name: `${orgName} - ${projectName}`,
|
name: `${orgName} - ${projectName}`,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue