PWA final fix
This commit is contained in:
@@ -19,15 +19,10 @@ export class AuthInterceptor implements HttpInterceptor {
|
||||
) { }
|
||||
|
||||
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
||||
console.log('Welcome to interceptor:', request.url);
|
||||
console.log('IsAuth?', request.url.includes('/auth/apiToken'));
|
||||
if (!request.url.includes('/auth/apiToken')) {
|
||||
console.log(this.auth$.expirationTime.format(), moment.utc().format());
|
||||
if (this.auth$.expirationTime.isBefore(moment.utc())) {
|
||||
console.log('Need to refresh token');
|
||||
return this.auth$.getAPITokenObservable().pipe(
|
||||
mergeMap(() => {
|
||||
console.log('New token is ready');
|
||||
return next.handle(request.clone({
|
||||
headers: request.headers.set('Authorization', `Bearer ${this.auth$.apiToken}`),
|
||||
}));
|
||||
@@ -43,7 +38,6 @@ export class AuthInterceptor implements HttpInterceptor {
|
||||
})
|
||||
);
|
||||
} else {
|
||||
console.log('TOken is fine');
|
||||
return next.handle(request.clone({
|
||||
headers: request.headers.set('Authorization', `Bearer ${this.auth$.apiToken}`),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user