diff --git a/src/controllers/RunnerSelfServiceController.ts b/src/controllers/RunnerSelfServiceController.ts index 7b2d5ef..b70299a 100644 --- a/src/controllers/RunnerSelfServiceController.ts +++ b/src/controllers/RunnerSelfServiceController.ts @@ -104,17 +104,21 @@ export class RunnerSelfServiceController { return responseScans; } - @Get('/stations/me') - @UseBefore(ScanAuth) - @ResponseSchema(ResponseScanStation) - @ResponseSchema(ScanStationNotFoundError, { statusCode: 404 }) - @OnUndefined(ScanStationNotFoundError) - @OpenAPI({ description: 'Lists basic information about the station whose token got provided.
This includes it\'s associated track.', security: [{ "StationApiToken": [] }] }) - async getStationMe(@Req() req: Request) { - let scan = await this.stationRepository.findOne({ id: parseInt(req.headers["station_id"].toString()) }, { relations: ['track'] }) - if (!scan) { throw new ScanStationNotFoundError(); } - return scan.toResponse(); - } + @Get('/stations/me') + @UseBefore(ScanAuth) + @ResponseSchema(ResponseScanStation) + @ResponseSchema(ScanStationNotFoundError, { statusCode: 404 }) + @OnUndefined(ScanStationNotFoundError) + @OpenAPI({ description: 'Lists basic information about the station whose token got provided.
This includes it\'s associated track.', security: [{ "StationApiToken": [] }] }) + async getStationMe(@Req() req: Request) { + // ScanAuth middleware sets req.stationId (not a header) + if (!req.stationId) { + throw new ScanStationNotFoundError(); + } + let scan = await this.stationRepository.findOne({ id: req.stationId }, { relations: ['track'] }) + if (!scan) { throw new ScanStationNotFoundError(); } + return scan.toResponse(); + } @Post('/runners/login') @ResponseSchema(RunnerNotFoundError, { statusCode: 404 })