From 565fc8a3c92f2115c3d86e0b91a19b0b2ce5b0df Mon Sep 17 00:00:00 2001 From: Jannic Veith Date: Thu, 29 Aug 2024 14:17:55 +0200 Subject: [PATCH 1/2] Handle emails which include underscores, remove duplicate code in map --- .../server-asset-sg/src/core/middleware/jwt.middleware.ts | 2 +- libs/asset-viewer/src/lib/components/map/map.component.ts | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/apps/server-asset-sg/src/core/middleware/jwt.middleware.ts b/apps/server-asset-sg/src/core/middleware/jwt.middleware.ts index 89582cc3..28395ea5 100644 --- a/apps/server-asset-sg/src/core/middleware/jwt.middleware.ts +++ b/apps/server-asset-sg/src/core/middleware/jwt.middleware.ts @@ -190,7 +190,7 @@ export class JwtMiddleware implements NestMiddleware { if (!('username' in payload) || payload.username.length === 0) { throw new HttpException('invalid JWT payload: missing username', 401); } - const email = payload.username.split('_')[1]; + const email = payload.username.split('_').slice(1).join(''); if (email == null || !/^.+@.+\..+$/.test(email)) { throw new HttpException('invalid JWT payload: username does not contain an email', 401); } diff --git a/libs/asset-viewer/src/lib/components/map/map.component.ts b/libs/asset-viewer/src/lib/components/map/map.component.ts index 4450b9a1..4882c9d2 100644 --- a/libs/asset-viewer/src/lib/components/map/map.component.ts +++ b/libs/asset-viewer/src/lib/components/map/map.component.ts @@ -146,15 +146,9 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy { this.subscription.add( studies$.subscribe((studies) => { this.controller.setStudies(studies); + setTimeout(() => this.initializeEnd.emit()); }) ); - - this.controller.isInitialized$ - .pipe( - first(identity), - switchMap(() => studies$) - ) - .subscribe(() => this.initializeEnd.emit()); } private initializeStoreBindings() { From 85404561626cc3e7952bab42a54a2533be9062ed Mon Sep 17 00:00:00 2001 From: Jannic Veith Date: Tue, 3 Sep 2024 08:46:43 +0200 Subject: [PATCH 2/2] Dont replace underscores --- apps/server-asset-sg/src/core/middleware/jwt.middleware.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/server-asset-sg/src/core/middleware/jwt.middleware.ts b/apps/server-asset-sg/src/core/middleware/jwt.middleware.ts index 28395ea5..8d1fc4f1 100644 --- a/apps/server-asset-sg/src/core/middleware/jwt.middleware.ts +++ b/apps/server-asset-sg/src/core/middleware/jwt.middleware.ts @@ -190,7 +190,7 @@ export class JwtMiddleware implements NestMiddleware { if (!('username' in payload) || payload.username.length === 0) { throw new HttpException('invalid JWT payload: missing username', 401); } - const email = payload.username.split('_').slice(1).join(''); + const email = payload.username.split('_').slice(1).join('_'); if (email == null || !/^.+@.+\..+$/.test(email)) { throw new HttpException('invalid JWT payload: username does not contain an email', 401); }