wt-front-shared 1.0.71 → 1.0.72
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.
- package/esm2020/lib/core/interceptors/headers.interceptor.mjs +39 -24
- package/fesm2015/wt-front-shared.mjs +38 -23
- package/fesm2015/wt-front-shared.mjs.map +1 -1
- package/fesm2020/wt-front-shared.mjs +38 -23
- package/fesm2020/wt-front-shared.mjs.map +1 -1
- package/lib/core/interceptors/headers.interceptor.d.ts +1 -0
- package/package.json +1 -1
|
@@ -12677,32 +12677,36 @@ class HeadersInterceptor {
|
|
|
12677
12677
|
try {
|
|
12678
12678
|
const userInfo = this.authenticationService.loadAuthDataFromLocalStore();
|
|
12679
12679
|
this.updateRequestData(request.urlWithParams, request.method, errResponse.error.formErrors);
|
|
12680
|
-
|
|
12681
|
-
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
|
|
12685
|
-
this.checkErrors(errResponse.error.formErrors);
|
|
12686
|
-
}
|
|
12687
|
-
if (errResponse.error.formId) {
|
|
12688
|
-
this.formsFacade.updateForm({
|
|
12689
|
-
formId: errResponse.error.formId,
|
|
12690
|
-
loading: false,
|
|
12691
|
-
hasError: true,
|
|
12692
|
-
isComplete: true,
|
|
12693
|
-
error: errResponse.error.error,
|
|
12694
|
-
code: errResponse.error.code
|
|
12695
|
-
});
|
|
12680
|
+
const currentHost = window.location.host;
|
|
12681
|
+
const requestDomain = this.getDomainByUrl(request.url);
|
|
12682
|
+
if (currentHost === requestDomain) {
|
|
12683
|
+
if (errResponse.status === 401) {
|
|
12684
|
+
return this.handle401Error(errResponse, userInfo, request, next);
|
|
12696
12685
|
}
|
|
12697
|
-
if (errResponse.error
|
|
12698
|
-
|
|
12699
|
-
|
|
12700
|
-
|
|
12686
|
+
if (errResponse.status === 422 && errResponse.error) {
|
|
12687
|
+
if (errResponse.error.formErrors) {
|
|
12688
|
+
this.checkErrors(errResponse.error.formErrors);
|
|
12689
|
+
}
|
|
12690
|
+
if (errResponse.error.formId) {
|
|
12691
|
+
this.formsFacade.updateForm({
|
|
12692
|
+
formId: errResponse.error.formId,
|
|
12693
|
+
loading: false,
|
|
12694
|
+
hasError: true,
|
|
12695
|
+
isComplete: true,
|
|
12696
|
+
error: errResponse.error.error,
|
|
12697
|
+
code: errResponse.error.code
|
|
12698
|
+
});
|
|
12699
|
+
}
|
|
12700
|
+
if (errResponse.error.data?.publicationResult) {
|
|
12701
|
+
const { errors, warnings } = errResponse.error.data.publicationResult;
|
|
12702
|
+
if (errors || warnings) {
|
|
12703
|
+
this.checkPublishErrors(errors, warnings);
|
|
12704
|
+
}
|
|
12701
12705
|
}
|
|
12702
12706
|
}
|
|
12703
|
-
|
|
12704
|
-
|
|
12705
|
-
|
|
12707
|
+
if (errResponse.status === 403) {
|
|
12708
|
+
this.sendForbiddenError();
|
|
12709
|
+
}
|
|
12706
12710
|
}
|
|
12707
12711
|
const error = (errResponse.error && errResponse.error.message) || errResponse.statusText;
|
|
12708
12712
|
return throwError(error);
|
|
@@ -12782,6 +12786,17 @@ class HeadersInterceptor {
|
|
|
12782
12786
|
console.error('[ headers.interceptor ][ intercept ][ handlePublicationMessagesAndFiles ]', e);
|
|
12783
12787
|
}
|
|
12784
12788
|
}
|
|
12789
|
+
getDomainByUrl(url, subdomain = false) {
|
|
12790
|
+
let newUrl = url.replace(/(https?:\/\/)?(www.)?/i, '');
|
|
12791
|
+
if (subdomain) {
|
|
12792
|
+
const urlParams = newUrl.split('.');
|
|
12793
|
+
newUrl = urlParams.slice(url.length - 2).join('.');
|
|
12794
|
+
}
|
|
12795
|
+
if (newUrl.indexOf('/') !== -1) {
|
|
12796
|
+
return newUrl.split('/')[0];
|
|
12797
|
+
}
|
|
12798
|
+
return newUrl;
|
|
12799
|
+
}
|
|
12785
12800
|
handle401Error(err, userInfo, request, next) {
|
|
12786
12801
|
console.error('[ header.interceptor ][ handle401Error ]', userInfo);
|
|
12787
12802
|
if (err.error.error === 'refresh-token-fail' ||
|