Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(tasks): prevent cross-workspace moves (#1384)

Tin Sever797380d2d6e4
diff --git a/apps/api/src/task/controllers/update-task.ts b/apps/api/src/task/controllers/update-task.ts
index b65c53fb6..069e35570 100644
--- a/apps/api/src/task/controllers/update-task.ts
+++ b/apps/api/src/task/controllers/update-task.ts
@@ -19,9 +19,16 @@ async function updateTask(
userId?: string,
currentUserId?: string,
) {
- const existingTask = await db.query.taskTable.findFirst({
- where: eq(taskTable.id, id),
- });
+ const [existingTask] = await db
+ .select({
+ id: taskTable.id,
+ description: taskTable.description,
+ status: taskTable.status,
+ projectId: taskTable.projectId,
+ })
+ .from(taskTable)
+ .where(eq(taskTable.id, id))
+ .limit(1);
if (!existingTask) {
throw new HTTPException(404, {
@@ -29,6 +36,12 @@ async function updateTask(
});
}
+ if (projectId !== existingTask.projectId) {
+ throw new HTTPException(400, {
+ message: "Use the task move endpoint to move tasks between projects",
+ });
+ }
+
await assertValidTaskStatus(status, projectId);
const column = await db.query.columnTable.findFirst({