THERE IS A RACE CONDITION BETWEEN USE AND REPEATED REFRESH OF A TOKEN

This commit is contained in:
Wolfgang Hottgenroth 2021-09-03 22:07:52 +02:00
parent 657d85538e
commit 606ac6d81f
Signed by: wn
GPG Key ID: E49AF3B9EF6DD469
4 changed files with 1 additions and 24 deletions

View File

@ -21,7 +21,7 @@ export class AuthHandlerInterceptor implements HttpInterceptor {
if (request.url.includes(serviceBaseUrl) && token) { if (request.url.includes(serviceBaseUrl) && token) {
this.messageService.add("start refresh of tokens") this.messageService.add("start refresh of tokens")
this.tokenService.refresh() this.tokenService.refresh()
this.messageService.add("api request intercepted") this.messageService.add("api request intercepted")
const clone = request.clone({ const clone = request.clone({
setHeaders: { Authorization: `Bearer ${token}`} setHeaders: { Authorization: `Bearer ${token}`}

View File

@ -28,7 +28,6 @@
</button> </button>
<span>Nober Grundbesitz GbR Hausverwaltung</span> <span>Nober Grundbesitz GbR Hausverwaltung</span>
<span class="spacer"></span> <span class="spacer"></span>
<span class="gittagversion">Expires in: {{expiresIn}} seconds</span>
<span class="gittagversion">GITTAGVERSION</span> <span class="gittagversion">GITTAGVERSION</span>
<a *ngIf="!authenticated" mat-button routerLink="/login">Login</a> <a *ngIf="!authenticated" mat-button routerLink="/login">Login</a>
<a *ngIf="authenticated" mat-button routerLink="/logout">Logout</a> <a *ngIf="authenticated" mat-button routerLink="/logout">Logout</a>

View File

@ -15,7 +15,6 @@ import { NavigationEnd, Router } from '@angular/router';
export class NavigationComponent { export class NavigationComponent {
public authenticated: boolean public authenticated: boolean
expiresIn: number
isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset) isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset)
.pipe( .pipe(
@ -36,7 +35,6 @@ export class NavigationComponent {
ngOnInit() { ngOnInit() {
this.authenticated = this.tokenService.checkAuthenticated() this.authenticated = this.tokenService.checkAuthenticated()
this.expiresIn = 600
} }
} }

View File

@ -80,24 +80,4 @@ export class TokenService {
this.messageService.add("Token removed from local storage") this.messageService.add("Token removed from local storage")
} }
} }
expiryUpdate() : Observable<number> {
const exUp = new Observable<number>((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
}
} }