Skip to content

armgit / TREK

Public Imported from GitHub
0

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.

fix(roadtrip): make the addon gate on the REST routes actually run

Mauriced1a13058a647
diff --git a/server/src/nest/roadtrip/roadtrip.controller.ts b/server/src/nest/roadtrip/roadtrip.controller.ts
index a706ff10c..b135687a7 100644
--- a/server/src/nest/roadtrip/roadtrip.controller.ts
+++ b/server/src/nest/roadtrip/roadtrip.controller.ts
@@ -5,6 +5,7 @@ import { RoadtripViaCreateDto, RoadtripViaReanchorDto, RoadtripViaUpdateDto } fr
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { RequirePermission, TripAccessGuard } from '../permissions/trip-access.guard';
import { RequireAddon } from '../addons/require-addon.decorator';
+import { AddonGuard } from '../addons/addon.guard';
import { ADDON_IDS } from '../../addons';
/**
@@ -20,7 +21,11 @@ import { ADDON_IDS } from '../../addons';
* become shared editing rather than route shaping.
*/
@Controller('api/trips/:tripId/roadtrip')
-@UseGuards(JwtAuthGuard, TripAccessGuard)
+// AddonGuard FIRST: @RequireAddon is metadata and does nothing on its own, and the guard
+// is not registered globally either, so without it here the decorator below was inert and
+// all six routes answered on an instance that had the addon switched off. It leads the
+// chain because a disabled addon owes an anonymous caller a 404, not a 401.
+@UseGuards(AddonGuard, JwtAuthGuard, TripAccessGuard)
@RequireAddon(ADDON_IDS.ROADTRIP, 'Road trip')
export class RoadtripController {
constructor(private readonly roadtrip: RoadtripService) {}