From f84e1966e152abb9bf86d04d75964f96156b90e3 Mon Sep 17 00:00:00 2001 From: Tom Winter Date: Tue, 20 Feb 2024 23:22:41 +0100 Subject: [PATCH] fix: stop forwarding jwt token to couchdb --- src/couchdb/couch-db-client.service.ts | 4 ++-- src/report/controller/report-calculation.controller.ts | 2 +- src/report/repository/report-repository.service.ts | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/couchdb/couch-db-client.service.ts b/src/couchdb/couch-db-client.service.ts index 2aedceb..67aa8e0 100644 --- a/src/couchdb/couch-db-client.service.ts +++ b/src/couchdb/couch-db-client.service.ts @@ -131,6 +131,8 @@ export class CouchDbClient { } private handleError(err: any) { + console.error(err); + if (err.response?.status === 401) { throw new UnauthorizedException(); } @@ -140,8 +142,6 @@ export class CouchDbClient { if (err.response?.status === 404) { throw new NotFoundException(); } - - console.error(err); throw new InternalServerErrorException(); } } diff --git a/src/report/controller/report-calculation.controller.ts b/src/report/controller/report-calculation.controller.ts index 3abe99d..2cf83b2 100644 --- a/src/report/controller/report-calculation.controller.ts +++ b/src/report/controller/report-calculation.controller.ts @@ -29,7 +29,7 @@ export class ReportCalculationController { @Headers('Authorization') token: string, @Param('reportId') reportId: string, ): Observable { - return this.reportStorage.fetchReport(new Reference(reportId), token).pipe( + return this.reportStorage.fetchReport(new Reference(reportId)).pipe( switchMap((value) => { if (!value) { throw new NotFoundException(); diff --git a/src/report/repository/report-repository.service.ts b/src/report/repository/report-repository.service.ts index a6e5b22..caced81 100644 --- a/src/report/repository/report-repository.service.ts +++ b/src/report/repository/report-repository.service.ts @@ -88,6 +88,8 @@ export class ReportRepository { } private handleError(err: any) { + console.error(err); + if (err.response.status === 401) { throw new UnauthorizedException(); }