From 565fc8a3c92f2115c3d86e0b91a19b0b2ce5b0df Mon Sep 17 00:00:00 2001 From: Jannic Veith Date: Thu, 29 Aug 2024 14:17:55 +0200 Subject: [PATCH] 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() {