acsi-core 1.2.41 → 1.2.43
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/dist/index.js +46 -17
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +46 -17
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1730,6 +1730,10 @@ var apiUpload = axios.create({
|
|
|
1730
1730
|
if (imPersonate) {
|
|
1731
1731
|
config.headers.ImPersonate = imPersonate;
|
|
1732
1732
|
}
|
|
1733
|
+
var tenantId = localStorage.getItem(ORGANIZATION_TENANT);
|
|
1734
|
+
if (tenantId) {
|
|
1735
|
+
config.headers["X-TenantId"] = tenantId;
|
|
1736
|
+
}
|
|
1733
1737
|
return config;
|
|
1734
1738
|
}, function (error) {
|
|
1735
1739
|
return Promise.reject(error);
|
|
@@ -1737,25 +1741,50 @@ var apiUpload = axios.create({
|
|
|
1737
1741
|
});
|
|
1738
1742
|
[api, apiUpload].forEach(function (i) {
|
|
1739
1743
|
return i.interceptors.response.use(function (response) {
|
|
1744
|
+
if (response.data && response.data.message === "RedirectToTenantDomain" && response.data.redirectDomain) {
|
|
1745
|
+
var token = localStorage.getItem(ACCESS_TOKEN) || "";
|
|
1746
|
+
var redirectUrl = response.data.redirectDomain;
|
|
1747
|
+
if (!/^https?:\/\//i.test(redirectUrl)) {
|
|
1748
|
+
redirectUrl = window.location.protocol + "//" + redirectUrl;
|
|
1749
|
+
}
|
|
1750
|
+
redirectUrl = redirectUrl.replace(/\/$/, "");
|
|
1751
|
+
window.location.href = redirectUrl + "/login?token=" + encodeURIComponent(token);
|
|
1752
|
+
return new Promise(function () {});
|
|
1753
|
+
}
|
|
1740
1754
|
return response;
|
|
1741
1755
|
}, function (error) {
|
|
1742
|
-
if (error.response
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1756
|
+
if (error.response && error.response.data) {
|
|
1757
|
+
var data = error.response.data;
|
|
1758
|
+
if (data.message === "RedirectToTenantDomain" && data.redirectDomain) {
|
|
1759
|
+
var token = localStorage.getItem(ACCESS_TOKEN) || "";
|
|
1760
|
+
var redirectUrl = data.redirectDomain;
|
|
1761
|
+
if (!/^https?:\/\//i.test(redirectUrl)) {
|
|
1762
|
+
redirectUrl = window.location.protocol + "//" + redirectUrl;
|
|
1763
|
+
}
|
|
1764
|
+
redirectUrl = redirectUrl.replace(/\/$/, "");
|
|
1765
|
+
window.location.href = redirectUrl + "/login?token=" + encodeURIComponent(token);
|
|
1766
|
+
return new Promise(function () {});
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
if (error.response) {
|
|
1770
|
+
if (error.response.status === 401) {
|
|
1771
|
+
window.location.href = "/login";
|
|
1772
|
+
}
|
|
1773
|
+
if (error.response.status == 403) {
|
|
1774
|
+
var hostname = window.location.hostname;
|
|
1775
|
+
var parts = hostname.split('.');
|
|
1776
|
+
var domain = parts.slice(-2).join('.');
|
|
1777
|
+
localStorage.removeItem(ACCESS_TOKEN);
|
|
1778
|
+
localStorage.removeItem(ORGANIZATION_TENANT);
|
|
1779
|
+
localStorage.removeItem(TIMEZONE_ID);
|
|
1780
|
+
localStorage.removeItem(ORGANIZATION_TEAM);
|
|
1781
|
+
Cookies.remove('auth', {
|
|
1782
|
+
path: '/',
|
|
1783
|
+
domain: "." + domain
|
|
1784
|
+
});
|
|
1785
|
+
localStorage.removeItem("USER_EMAIL");
|
|
1786
|
+
window.location.href = "/login";
|
|
1787
|
+
}
|
|
1759
1788
|
}
|
|
1760
1789
|
return Promise.reject(error);
|
|
1761
1790
|
});
|