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: project membership authorization check to the WebSocket /ws/:projectId endpoint

tiran1335dfb48b549ab
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index cfba58d77..eb5748976 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -535,6 +535,21 @@ export function createApp() {
}
const userId = c.get("userId");
+
+ if (projectId) {
+ const [project] = await db
+ .select({ workspaceId: schema.projectTable.workspaceId })
+ .from(schema.projectTable)
+ .where(eq(schema.projectTable.id, projectId))
+ .limit(1);
+
+ if (!project) {
+ throw new HTTPException(401, { message: "Unauthorized" });
+ }
+
+ await validateWorkspaceAccess(userId, project.workspaceId);
+ }
+
const windowId = c.req.query("windowId");
const initiatorId = windowId ? `${userId}:${windowId}` : userId;
let conn: ReturnType<typeof addConnection> | null = null;