THERE IS A RACE CONDITION BETWEEN USE AND REPEATED REFRESH OF A TOKEN
This commit is contained in:
parent
657d85538e
commit
606ac6d81f
@ -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}`}
|
||||
|
@ -28,7 +28,6 @@
|
||||
</button>
|
||||
<span>Nober Grundbesitz GbR Hausverwaltung</span>
|
||||
<span class="spacer"></span>
|
||||
<span class="gittagversion">Expires in: {{expiresIn}} seconds</span>
|
||||
<span class="gittagversion">GITTAGVERSION</span>
|
||||
<a *ngIf="!authenticated" mat-button routerLink="/login">Login</a>
|
||||
<a *ngIf="authenticated" mat-button routerLink="/logout">Logout</a>
|
||||
|
@ -15,7 +15,6 @@ import { NavigationEnd, Router } from '@angular/router';
|
||||
export class NavigationComponent {
|
||||
|
||||
public authenticated: boolean
|
||||
expiresIn: number
|
||||
|
||||
isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset)
|
||||
.pipe(
|
||||
@ -36,7 +35,6 @@ export class NavigationComponent {
|
||||
|
||||
ngOnInit() {
|
||||
this.authenticated = this.tokenService.checkAuthenticated()
|
||||
this.expiresIn = 600
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -80,24 +80,4 @@ export class TokenService {
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user