From 606ac6d81f24e9a899b310ba1f78ef2e98d0b6ce Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Fri, 3 Sep 2021 22:07:52 +0200 Subject: [PATCH] THERE IS A RACE CONDITION BETWEEN USE AND REPEATED REFRESH OF A TOKEN --- ui/hv2-ui/src/app/auth-handler.interceptor.ts | 2 +- .../app/navigation/navigation.component.html | 1 - .../app/navigation/navigation.component.ts | 2 -- ui/hv2-ui/src/app/token.service.ts | 20 ------------------- 4 files changed, 1 insertion(+), 24 deletions(-) diff --git a/ui/hv2-ui/src/app/auth-handler.interceptor.ts b/ui/hv2-ui/src/app/auth-handler.interceptor.ts index 4a0c8b9..be24dc1 100644 --- a/ui/hv2-ui/src/app/auth-handler.interceptor.ts +++ b/ui/hv2-ui/src/app/auth-handler.interceptor.ts @@ -21,7 +21,7 @@ export class AuthHandlerInterceptor implements HttpInterceptor { if (request.url.includes(serviceBaseUrl) && token) { this.messageService.add("start refresh of tokens") this.tokenService.refresh() - + this.messageService.add("api request intercepted") const clone = request.clone({ setHeaders: { Authorization: `Bearer ${token}`} diff --git a/ui/hv2-ui/src/app/navigation/navigation.component.html b/ui/hv2-ui/src/app/navigation/navigation.component.html index 32f1880..4f76fe5 100644 --- a/ui/hv2-ui/src/app/navigation/navigation.component.html +++ b/ui/hv2-ui/src/app/navigation/navigation.component.html @@ -28,7 +28,6 @@ Nober Grundbesitz GbR Hausverwaltung - Expires in: {{expiresIn}} seconds GITTAGVERSION Login Logout diff --git a/ui/hv2-ui/src/app/navigation/navigation.component.ts b/ui/hv2-ui/src/app/navigation/navigation.component.ts index 13eb4b0..980d0ee 100644 --- a/ui/hv2-ui/src/app/navigation/navigation.component.ts +++ b/ui/hv2-ui/src/app/navigation/navigation.component.ts @@ -15,7 +15,6 @@ import { NavigationEnd, Router } from '@angular/router'; export class NavigationComponent { public authenticated: boolean - expiresIn: number isHandset$: Observable = this.breakpointObserver.observe(Breakpoints.Handset) .pipe( @@ -36,7 +35,6 @@ export class NavigationComponent { ngOnInit() { this.authenticated = this.tokenService.checkAuthenticated() - this.expiresIn = 600 } } diff --git a/ui/hv2-ui/src/app/token.service.ts b/ui/hv2-ui/src/app/token.service.ts index 23e88cf..9b5b7e3 100644 --- a/ui/hv2-ui/src/app/token.service.ts +++ b/ui/hv2-ui/src/app/token.service.ts @@ -80,24 +80,4 @@ export class TokenService { this.messageService.add("Token removed from local storage") } } - - expiryUpdate() : Observable { - const exUp = new Observable((observer) => { - let i = 600 - - while (i != 0) { - observer.next(i) - i -= 1 - await new Promise(f => setTimeout(f, 1000)) - } - observer.complete() - - return { - unsubscribe() { - } - } - }) - return exUp - } - }