Skip to content

Commit

Permalink
Merge pull request #259 from swisstopo/bug/assets-258_user-emails-wro…
Browse files Browse the repository at this point in the history
…ngly-validated

Handle emails which include underscores, remove duplicate code in map
  • Loading branch information
vej-ananas authored Sep 3, 2024
2 parents c87f5c5 + 8540456 commit da8d712
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/server-asset-sg/src/core/middleware/jwt.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,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);
}
Expand Down
8 changes: 1 addition & 7 deletions libs/asset-viewer/src/lib/components/map/map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit da8d712

Please sign in to comment.