The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix: restrict trip listing and access to own/shared trips only (#250)
Maurice8c85ea364480
diff --git a/server/src/routes/trips.ts b/server/src/routes/trips.tsindex f400a6535..4b5cbac06 100644--- a/server/src/routes/trips.ts+++ b/server/src/routes/trips.ts@@ -126,19 +126,12 @@ router.get('/', authenticate, (req: Request, res: Response) => {const authReq = req as AuthRequest;const archived = req.query.archived === '1' ? 1 : 0;const userId = authReq.user.id;- const isAdminUser = authReq.user.role === 'admin';- const trips = isAdminUser- ? db.prepare(`- ${TRIP_SELECT}- WHERE t.is_archived = :archived- ORDER BY t.created_at DESC- `).all({ userId, archived })- : db.prepare(`- ${TRIP_SELECT}- LEFT JOIN trip_members m ON m.trip_id = t.id AND m.user_id = :userId- WHERE (t.user_id = :userId OR m.user_id IS NOT NULL) AND t.is_archived = :archived- ORDER BY t.created_at DESC- `).all({ userId, archived });+ const trips = db.prepare(`+ ${TRIP_SELECT}+ LEFT JOIN trip_members m ON m.trip_id = t.id AND m.user_id = :userId+ WHERE (t.user_id = :userId OR m.user_id IS NOT NULL) AND t.is_archived = :archived+ ORDER BY t.created_at DESC+ `).all({ userId, archived });res.json({ trips });});@@ -171,14 +164,11 @@ router.post('/', authenticate, (req: Request, res: Response) => {router.get('/:id', authenticate, (req: Request, res: Response) => {const authReq = req as AuthRequest;const userId = authReq.user.id;- const isAdminUser = authReq.user.role === 'admin';- const trip = isAdminUser- ? db.prepare(`${TRIP_SELECT} WHERE t.id = :tripId`).get({ userId, tripId: req.params.id })- : db.prepare(`- ${TRIP_SELECT}- LEFT JOIN trip_members m ON m.trip_id = t.id AND m.user_id = :userId- WHERE t.id = :tripId AND (t.user_id = :userId OR m.user_id IS NOT NULL)- `).get({ userId, tripId: req.params.id });+ const trip = db.prepare(`+ ${TRIP_SELECT}+ LEFT JOIN trip_members m ON m.trip_id = t.id AND m.user_id = :userId+ WHERE t.id = :tripId AND (t.user_id = :userId OR m.user_id IS NOT NULL)+ `).get({ userId, tripId: req.params.id });if (!trip) return res.status(404).json({ error: 'Trip not found' });res.json({ trip });});