mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-20 02:58:53 +00:00
Merge pull request #3251 from Dokploy/3247-cannot-edit-production-environment-variables
fix(environment): prevent renaming of the default environment
This commit is contained in:
@@ -208,6 +208,14 @@ export const environmentRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prevent deletion of the default environment
|
||||||
|
if (environment.isDefault) {
|
||||||
|
throw new TRPCError({
|
||||||
|
code: "BAD_REQUEST",
|
||||||
|
message: "You cannot delete the default environment",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Check environment deletion permission
|
// Check environment deletion permission
|
||||||
await checkEnvironmentDeletionPermission(
|
await checkEnvironmentDeletionPermission(
|
||||||
ctx.user.id,
|
ctx.user.id,
|
||||||
@@ -256,10 +264,11 @@ export const environmentRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
const currentEnvironment = await findEnvironmentById(environmentId);
|
const currentEnvironment = await findEnvironmentById(environmentId);
|
||||||
|
|
||||||
if (currentEnvironment.isDefault) {
|
// Prevent renaming the default environment, but allow updating env and description
|
||||||
|
if (currentEnvironment.isDefault && updateData.name !== undefined) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
message: "You cannot update the default environment",
|
message: "You cannot rename the default environment",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user