debug
This commit is contained in:
@@ -19,10 +19,15 @@ export class AuthInterceptor implements HttpInterceptor {
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
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')) {
|
if (!request.url.includes('/auth/apiToken')) {
|
||||||
|
console.log(this.auth$.expirationTime.format(), moment.utc().format());
|
||||||
if (this.auth$.expirationTime.isBefore(moment.utc())) {
|
if (this.auth$.expirationTime.isBefore(moment.utc())) {
|
||||||
|
console.log('Need to refresh token');
|
||||||
return this.auth$.getAPITokenObservable().pipe(
|
return this.auth$.getAPITokenObservable().pipe(
|
||||||
mergeMap(() => {
|
mergeMap(() => {
|
||||||
|
console.log('New token is ready');
|
||||||
return next.handle(request.clone({
|
return next.handle(request.clone({
|
||||||
headers: request.headers.set('Authorization', `Bearer ${this.auth$.apiToken}`),
|
headers: request.headers.set('Authorization', `Bearer ${this.auth$.apiToken}`),
|
||||||
}));
|
}));
|
||||||
@@ -38,6 +43,7 @@ export class AuthInterceptor implements HttpInterceptor {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
console.log('TOken is fine');
|
||||||
return next.handle(request.clone({
|
return next.handle(request.clone({
|
||||||
headers: request.headers.set('Authorization', `Bearer ${this.auth$.apiToken}`),
|
headers: request.headers.set('Authorization', `Bearer ${this.auth$.apiToken}`),
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ export const environment = {
|
|||||||
appEnvironment: "local",
|
appEnvironment: "local",
|
||||||
production: false,
|
production: false,
|
||||||
api: {
|
api: {
|
||||||
url: "http://localhost:5400/api"
|
//url: "http://localhost:5400/api"
|
||||||
// url: "https://diunabi.bim-it.pl/api"
|
url: "https://diunabi.bim-it.pl/api"
|
||||||
},
|
},
|
||||||
google: {
|
google: {
|
||||||
clientId: "107631825312-bkfe438ehr9k9ecb2h76g802tj6advma.apps.googleusercontent.com"
|
clientId: "107631825312-bkfe438ehr9k9ecb2h76g802tj6advma.apps.googleusercontent.com"
|
||||||
|
|||||||
Reference in New Issue
Block a user