Fix: Search-Route vor :id-Route registriert, damit /api/tasks/search nicht als Task-ID interpretiert wird
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1116,6 +1116,18 @@ ${activeTasksWithLabels.slice(0, 5).map(t => `- [${t.priority}] [${t.label}] ${t
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Search tasks - MUST be before /api/tasks/:id to avoid route conflict
|
||||||
|
app.get("/api/tasks/search", async (req, res) => {
|
||||||
|
if (!req.isAuthenticated()) return res.sendStatus(401);
|
||||||
|
try {
|
||||||
|
const query = (req.query.q as string) || "";
|
||||||
|
const tasks = await storage.searchTasks(query, (req.user as User).id);
|
||||||
|
res.json(tasks);
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: "Failed to search tasks" });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Helper for RBAC
|
// Helper for RBAC
|
||||||
const checkTaskAccess = async (user: User, taskId: string, requiredPermission: 'read' | 'write' = 'read'): Promise<{ hasAccess: boolean, task?: Task }> => {
|
const checkTaskAccess = async (user: User, taskId: string, requiredPermission: 'read' | 'write' = 'read'): Promise<{ hasAccess: boolean, task?: Task }> => {
|
||||||
const task = await storage.getTask(taskId);
|
const task = await storage.getTask(taskId);
|
||||||
|
|||||||
Reference in New Issue
Block a user