@progress-chef/platform-http-interceptor 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
1
|
+
import { Inject, Injectable } from '@angular/core';
|
|
2
2
|
import { LocalStorageService, StorageKeys } from '@progress-chef/platform-storage-service';
|
|
3
3
|
import { catchError, throwError } from 'rxjs';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
import * as i1 from "@progress-chef/platform-shared-components";
|
|
6
6
|
import * as i2 from "@progress-chef/platform-shared-store";
|
|
7
7
|
export class HttpAuthInterceptor {
|
|
8
|
-
constructor(toastNotificationService, chefPlatformUserAccountsIdentitySharedFacadeService) {
|
|
8
|
+
constructor(getBaseUrl, toastNotificationService, chefPlatformUserAccountsIdentitySharedFacadeService) {
|
|
9
|
+
this.getBaseUrl = getBaseUrl;
|
|
9
10
|
this.toastNotificationService = toastNotificationService;
|
|
10
11
|
this.chefPlatformUserAccountsIdentitySharedFacadeService = chefPlatformUserAccountsIdentitySharedFacadeService;
|
|
11
12
|
}
|
|
@@ -26,31 +27,40 @@ export class HttpAuthInterceptor {
|
|
|
26
27
|
}
|
|
27
28
|
LocalStorageService.setItem(StorageKeys.IS_USER_ORG_AND_ROLE_SET, false);
|
|
28
29
|
LocalStorageService.setItem(StorageKeys.IS_USER_AUTHENTICATED, false);
|
|
29
|
-
LocalStorageService.removeItem(StorageKeys.AUTH_TOKEN);
|
|
30
30
|
LocalStorageService.removeItem(StorageKeys.LOGIN_TYPE);
|
|
31
31
|
LocalStorageService.removeItem(StorageKeys.IDENTITY_TOKEN);
|
|
32
32
|
LocalStorageService.removeItem(StorageKeys.USER_ORG_AND_ROLE_TOKEN);
|
|
33
33
|
// call logout action
|
|
34
34
|
this.chefPlatformUserAccountsIdentitySharedFacadeService.identityLogoutIdentity({
|
|
35
|
-
baseUrl:
|
|
35
|
+
baseUrl: this.getBaseUrl
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
if (error.status === 0) {
|
|
38
|
+
if (error.status === 0 || error.status === 504) {
|
|
39
39
|
this.toastNotificationService.showToastNotification({
|
|
40
40
|
content: `Unable to reach server. Please try again.`,
|
|
41
41
|
type: { style: 'error', icon: true },
|
|
42
42
|
closable: true
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
+
if (error.status === 500) {
|
|
46
|
+
this.toastNotificationService.showToastNotification({
|
|
47
|
+
content: `Something went wrong. Please try again.`,
|
|
48
|
+
type: { style: 'error', icon: true },
|
|
49
|
+
closable: true
|
|
50
|
+
});
|
|
51
|
+
}
|
|
45
52
|
return throwError(() => error);
|
|
46
53
|
}));
|
|
47
54
|
}
|
|
48
55
|
return next.handle(request);
|
|
49
56
|
}
|
|
50
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HttpAuthInterceptor, deps: [{ token: i1.ToastNotificationService }, { token: i2.ChefPlatformUserAccountsIdentitySharedFacadeService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
57
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HttpAuthInterceptor, deps: [{ token: 'BASE_URL' }, { token: i1.ToastNotificationService }, { token: i2.ChefPlatformUserAccountsIdentitySharedFacadeService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
51
58
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HttpAuthInterceptor }); }
|
|
52
59
|
}
|
|
53
60
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HttpAuthInterceptor, decorators: [{
|
|
54
61
|
type: Injectable
|
|
55
|
-
}], ctorParameters: function () { return [{ type:
|
|
56
|
-
|
|
62
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
63
|
+
type: Inject,
|
|
64
|
+
args: ['BASE_URL']
|
|
65
|
+
}] }, { type: i1.ToastNotificationService }, { type: i2.ChefPlatformUserAccountsIdentitySharedFacadeService }]; } });
|
|
66
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHR0cC1hdXRoLmludGVyY2VwdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvcGxhdGZvcm0taHR0cC1pbnRlcmNlcHRvci9zcmMvbGliL2h0dHAtYXV0aC5pbnRlcmNlcHRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFPQSxPQUFPLEVBQUUsTUFBTSxFQUFFLFVBQVUsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUduRCxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsV0FBVyxFQUFFLE1BQU0seUNBQXlDLENBQUM7QUFDM0YsT0FBTyxFQUFjLFVBQVUsRUFBRSxVQUFVLEVBQUUsTUFBTSxNQUFNLENBQUM7Ozs7QUFHMUQsTUFBTSxPQUFPLG1CQUFtQjtJQUM5QixZQUF3QyxVQUFrQixFQUFVLHdCQUFrRCxFQUFVLG1EQUF3RztRQUFoTSxlQUFVLEdBQVYsVUFBVSxDQUFRO1FBQVUsNkJBQXdCLEdBQXhCLHdCQUF3QixDQUEwQjtRQUFVLHdEQUFtRCxHQUFuRCxtREFBbUQsQ0FBcUQ7SUFBSSxDQUFDO0lBRTdPLFNBQVMsQ0FBQyxPQUE2QixFQUFFLElBQWlCO1FBQ3hELElBQUksU0FBUyxHQUFHLG1CQUFtQixDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsVUFBVSxDQUFDLENBQUM7UUFFcEUsSUFBSSxTQUFTLEVBQUU7WUFDYixNQUFNLE9BQU8sR0FBRyxPQUFPLENBQUMsS0FBSyxDQUFDO2dCQUM1QixV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HJ1ZSB9LFxuICAgICAgICAgICAgICBjbG9zYWJsZTogdHJ1ZVxuICAgICAgICAgICAgfSlcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKGVycm9yLnN0YXR1cyA9PT0gNTAwKSB7XG4gICAgICAgICAgICB0aGlzLnRvYXN0Tm90aWZpY2F0aW9uU2VydmljZS5zaG93VG9hc3ROb3RpZmljYXRpb24oe1xuICAgICAgICAgICAgICBjb250ZW50OiBgU29tZXRoaW5nIHdlbnQgd3JvbmcuIFBsZWFzZSB0cnkgYWdhaW4uYCxcbiAgICAgICAgICAgICAgdHlwZTogeyBzdHlsZTogJ2Vycm9yJywgaWNvbjogdHJ1ZSB9LFxuICAgICAgICAgICAgICBjbG9zYWJsZTogdHJ1ZVxuICAgICAgICAgICAgfSlcbiAgICAgICAgICB9XG4gICAgICAgICAgcmV0dXJuIHRocm93RXJyb3IoKCkgPT4gZXJyb3IpXG4gICAgICAgIH0pXG4gICAgICApO1xuICAgIH1cbiAgICByZXR1cm4gbmV4dC5oYW5kbGUocmVxdWVzdClcbiAgfVxufVxuIl19
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable } from '@angular/core';
|
|
2
|
+
import { Injectable, Inject } from '@angular/core';
|
|
3
3
|
import { LocalStorageService, StorageKeys } from '@progress-chef/platform-storage-service';
|
|
4
4
|
import { catchError, throwError } from 'rxjs';
|
|
5
5
|
import * as i1 from '@progress-chef/platform-shared-components';
|
|
6
6
|
import * as i2 from '@progress-chef/platform-shared-store';
|
|
7
7
|
|
|
8
8
|
class HttpAuthInterceptor {
|
|
9
|
-
constructor(toastNotificationService, chefPlatformUserAccountsIdentitySharedFacadeService) {
|
|
9
|
+
constructor(getBaseUrl, toastNotificationService, chefPlatformUserAccountsIdentitySharedFacadeService) {
|
|
10
|
+
this.getBaseUrl = getBaseUrl;
|
|
10
11
|
this.toastNotificationService = toastNotificationService;
|
|
11
12
|
this.chefPlatformUserAccountsIdentitySharedFacadeService = chefPlatformUserAccountsIdentitySharedFacadeService;
|
|
12
13
|
}
|
|
@@ -27,33 +28,42 @@ class HttpAuthInterceptor {
|
|
|
27
28
|
}
|
|
28
29
|
LocalStorageService.setItem(StorageKeys.IS_USER_ORG_AND_ROLE_SET, false);
|
|
29
30
|
LocalStorageService.setItem(StorageKeys.IS_USER_AUTHENTICATED, false);
|
|
30
|
-
LocalStorageService.removeItem(StorageKeys.AUTH_TOKEN);
|
|
31
31
|
LocalStorageService.removeItem(StorageKeys.LOGIN_TYPE);
|
|
32
32
|
LocalStorageService.removeItem(StorageKeys.IDENTITY_TOKEN);
|
|
33
33
|
LocalStorageService.removeItem(StorageKeys.USER_ORG_AND_ROLE_TOKEN);
|
|
34
34
|
// call logout action
|
|
35
35
|
this.chefPlatformUserAccountsIdentitySharedFacadeService.identityLogoutIdentity({
|
|
36
|
-
baseUrl:
|
|
36
|
+
baseUrl: this.getBaseUrl
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
if (error.status === 0) {
|
|
39
|
+
if (error.status === 0 || error.status === 504) {
|
|
40
40
|
this.toastNotificationService.showToastNotification({
|
|
41
41
|
content: `Unable to reach server. Please try again.`,
|
|
42
42
|
type: { style: 'error', icon: true },
|
|
43
43
|
closable: true
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
+
if (error.status === 500) {
|
|
47
|
+
this.toastNotificationService.showToastNotification({
|
|
48
|
+
content: `Something went wrong. Please try again.`,
|
|
49
|
+
type: { style: 'error', icon: true },
|
|
50
|
+
closable: true
|
|
51
|
+
});
|
|
52
|
+
}
|
|
46
53
|
return throwError(() => error);
|
|
47
54
|
}));
|
|
48
55
|
}
|
|
49
56
|
return next.handle(request);
|
|
50
57
|
}
|
|
51
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HttpAuthInterceptor, deps: [{ token: i1.ToastNotificationService }, { token: i2.ChefPlatformUserAccountsIdentitySharedFacadeService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
58
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HttpAuthInterceptor, deps: [{ token: 'BASE_URL' }, { token: i1.ToastNotificationService }, { token: i2.ChefPlatformUserAccountsIdentitySharedFacadeService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
52
59
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HttpAuthInterceptor }); }
|
|
53
60
|
}
|
|
54
61
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: HttpAuthInterceptor, decorators: [{
|
|
55
62
|
type: Injectable
|
|
56
|
-
}], ctorParameters: function () { return [{ type:
|
|
63
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
64
|
+
type: Inject,
|
|
65
|
+
args: ['BASE_URL']
|
|
66
|
+
}] }, { type: i1.ToastNotificationService }, { type: i2.ChefPlatformUserAccountsIdentitySharedFacadeService }]; } });
|
|
57
67
|
|
|
58
68
|
/*
|
|
59
69
|
* Public API Surface of platform-http-interceptor
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress-chef-platform-http-interceptor.mjs","sources":["../../../projects/platform-http-interceptor/src/lib/http-auth.interceptor.ts","../../../projects/platform-http-interceptor/src/public-api.ts","../../../projects/platform-http-interceptor/src/progress-chef-platform-http-interceptor.ts"],"sourcesContent":["import {\n HttpErrorResponse,\n HttpEvent,\n HttpHandler,\n HttpInterceptor,\n HttpRequest\n} from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { ToastNotificationService } from '@progress-chef/platform-shared-components';\nimport { ChefPlatformUserAccountsIdentitySharedFacadeService } from '@progress-chef/platform-shared-store';\nimport { LocalStorageService, StorageKeys } from '@progress-chef/platform-storage-service';\nimport { Observable, catchError, throwError } from 'rxjs';\n\n@Injectable()\nexport class HttpAuthInterceptor implements HttpInterceptor {\n constructor(private toastNotificationService: ToastNotificationService, private chefPlatformUserAccountsIdentitySharedFacadeService: ChefPlatformUserAccountsIdentitySharedFacadeService) { }\n\n intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {\n let authToken = LocalStorageService.getItem(StorageKeys.AUTH_TOKEN);\n\n if (authToken) {\n const authReq = request.clone({\n setHeaders: {\n Authorization: `Bearer ${authToken}`\n }\n })\n\n return next.handle(authReq).pipe(\n catchError((error: HttpErrorResponse) => {\n if (error.status === 401) {\n const loginType = LocalStorageService.getItem(StorageKeys.LOGIN_TYPE);\n if (loginType === 'saml' || loginType === 'oauth') {\n LocalStorageService.removeItem(StorageKeys.USER_NAME);\n LocalStorageService.removeItem(StorageKeys.IS_REMEMBER_ME);\n }\n LocalStorageService.setItem(StorageKeys.IS_USER_ORG_AND_ROLE_SET, false);\n LocalStorageService.setItem(StorageKeys.IS_USER_AUTHENTICATED, false);\n LocalStorageService.removeItem(StorageKeys.
|
|
1
|
+
{"version":3,"file":"progress-chef-platform-http-interceptor.mjs","sources":["../../../projects/platform-http-interceptor/src/lib/http-auth.interceptor.ts","../../../projects/platform-http-interceptor/src/public-api.ts","../../../projects/platform-http-interceptor/src/progress-chef-platform-http-interceptor.ts"],"sourcesContent":["import {\n HttpErrorResponse,\n HttpEvent,\n HttpHandler,\n HttpInterceptor,\n HttpRequest\n} from '@angular/common/http';\nimport { Inject, Injectable } from '@angular/core';\nimport { ToastNotificationService } from '@progress-chef/platform-shared-components';\nimport { ChefPlatformUserAccountsIdentitySharedFacadeService } from '@progress-chef/platform-shared-store';\nimport { LocalStorageService, StorageKeys } from '@progress-chef/platform-storage-service';\nimport { Observable, catchError, throwError } from 'rxjs';\n\n@Injectable()\nexport class HttpAuthInterceptor implements HttpInterceptor {\n constructor(@Inject('BASE_URL') private getBaseUrl: string, private toastNotificationService: ToastNotificationService, private chefPlatformUserAccountsIdentitySharedFacadeService: ChefPlatformUserAccountsIdentitySharedFacadeService) { }\n\n intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {\n let authToken = LocalStorageService.getItem(StorageKeys.AUTH_TOKEN);\n\n if (authToken) {\n const authReq = request.clone({\n setHeaders: {\n Authorization: `Bearer ${authToken}`\n }\n })\n\n return next.handle(authReq).pipe(\n catchError((error: HttpErrorResponse) => {\n if (error.status === 401) {\n const loginType = LocalStorageService.getItem(StorageKeys.LOGIN_TYPE);\n if (loginType === 'saml' || loginType === 'oauth') {\n LocalStorageService.removeItem(StorageKeys.USER_NAME);\n LocalStorageService.removeItem(StorageKeys.IS_REMEMBER_ME);\n }\n LocalStorageService.setItem(StorageKeys.IS_USER_ORG_AND_ROLE_SET, false);\n LocalStorageService.setItem(StorageKeys.IS_USER_AUTHENTICATED, false);\n LocalStorageService.removeItem(StorageKeys.LOGIN_TYPE);\n LocalStorageService.removeItem(StorageKeys.IDENTITY_TOKEN);\n LocalStorageService.removeItem(StorageKeys.USER_ORG_AND_ROLE_TOKEN);\n // call logout action\n this.chefPlatformUserAccountsIdentitySharedFacadeService.identityLogoutIdentity({\n baseUrl: this.getBaseUrl\n });\n }\n if (error.status === 0 || error.status === 504) {\n this.toastNotificationService.showToastNotification({\n content: `Unable to reach server. Please try again.`,\n type: { style: 'error', icon: true },\n closable: true\n })\n }\n if (error.status === 500) {\n this.toastNotificationService.showToastNotification({\n content: `Something went wrong. Please try again.`,\n type: { style: 'error', icon: true },\n closable: true\n })\n }\n return throwError(() => error)\n })\n );\n }\n return next.handle(request)\n }\n}\n","/*\n * Public API Surface of platform-http-interceptor\n */\n\nexport * from './lib/http-auth.interceptor';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MAca,mBAAmB,CAAA;AAC9B,IAAA,WAAA,CAAwC,UAAkB,EAAU,wBAAkD,EAAU,mDAAwG,EAAA;QAAhM,IAAU,CAAA,UAAA,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,mDAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA,EAAA;mHADnB,mBAAmB,EAAA,CAAA,CAAA,EAAA;;4FAAnB,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAD/B,UAAU;;0BAEI,MAAM;2BAAC,UAAU,CAAA;;;ACfhC;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -4,9 +4,10 @@ import { ChefPlatformUserAccountsIdentitySharedFacadeService } from '@progress-c
|
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
import * as i0 from "@angular/core";
|
|
6
6
|
export declare class HttpAuthInterceptor implements HttpInterceptor {
|
|
7
|
+
private getBaseUrl;
|
|
7
8
|
private toastNotificationService;
|
|
8
9
|
private chefPlatformUserAccountsIdentitySharedFacadeService;
|
|
9
|
-
constructor(toastNotificationService: ToastNotificationService, chefPlatformUserAccountsIdentitySharedFacadeService: ChefPlatformUserAccountsIdentitySharedFacadeService);
|
|
10
|
+
constructor(getBaseUrl: string, toastNotificationService: ToastNotificationService, chefPlatformUserAccountsIdentitySharedFacadeService: ChefPlatformUserAccountsIdentitySharedFacadeService);
|
|
10
11
|
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>>;
|
|
11
12
|
static ɵfac: i0.ɵɵFactoryDeclaration<HttpAuthInterceptor, never>;
|
|
12
13
|
static ɵprov: i0.ɵɵInjectableDeclaration<HttpAuthInterceptor>;
|