mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 23:28:31 +00:00
feat(project-service): add unique slug check when creating project
This commit is contained in:
@@ -303,13 +303,26 @@ export const projectServiceFactory = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const slug = projectSlug || slugify(`${workspaceName}-${alphaNumericNanoId(4)}`);
|
||||||
|
|
||||||
|
const existingProject = await projectDAL.findOne({
|
||||||
|
slug,
|
||||||
|
orgId: organization.id
|
||||||
|
});
|
||||||
|
|
||||||
|
if (existingProject) {
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: `Failed to create project. A project with the slug "${slug}" already exists in your organization. Please choose a different name or slug.`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const project = await projectDAL.create(
|
const project = await projectDAL.create(
|
||||||
{
|
{
|
||||||
name: workspaceName,
|
name: workspaceName,
|
||||||
type,
|
type,
|
||||||
description: workspaceDescription,
|
description: workspaceDescription,
|
||||||
orgId: organization.id,
|
orgId: organization.id,
|
||||||
slug: projectSlug || slugify(`${workspaceName}-${alphaNumericNanoId(4)}`),
|
slug,
|
||||||
kmsSecretManagerKeyId: kmsKeyId,
|
kmsSecretManagerKeyId: kmsKeyId,
|
||||||
version: ProjectVersion.V3,
|
version: ProjectVersion.V3,
|
||||||
pitVersionLimit: 10
|
pitVersionLimit: 10
|
||||||
|
|||||||
Reference in New Issue
Block a user