@micha.bigler/ui-core-micha 2.1.11 → 2.1.12
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/auth/apiClient.js +5 -4
- package/package.json +1 -1
- package/src/auth/apiClient.jsx +7 -5
package/dist/auth/apiClient.js
CHANGED
|
@@ -46,10 +46,11 @@ apiClient.interceptors.response.use((response) => response, (error) => {
|
|
|
46
46
|
var _a, _b, _c, _d;
|
|
47
47
|
const status = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : null;
|
|
48
48
|
const data = (_d = (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) !== null && _d !== void 0 ? _d : {};
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
49
|
+
const code = typeof data.code === "string" ? data.code : null;
|
|
50
|
+
const i18nKey = typeof data.i18nKey === "string" ? data.i18nKey : null;
|
|
51
|
+
const isAuthStatus = status === 401 || status === 403;
|
|
52
|
+
const isNotAuthenticated = code === "not_authenticated" || i18nKey === "auth.not_authenticated";
|
|
53
|
+
if (isAuthStatus && isNotAuthenticated) {
|
|
53
54
|
redirectToLoginOnce();
|
|
54
55
|
}
|
|
55
56
|
return Promise.reject(error);
|
package/package.json
CHANGED
package/src/auth/apiClient.jsx
CHANGED
|
@@ -55,12 +55,14 @@ apiClient.interceptors.response.use(
|
|
|
55
55
|
(error) => {
|
|
56
56
|
const status = error?.response?.status ?? null;
|
|
57
57
|
const data = error?.response?.data ?? {};
|
|
58
|
-
const
|
|
58
|
+
const code = typeof data.code === "string" ? data.code : null;
|
|
59
|
+
const i18nKey = typeof data.i18nKey === "string" ? data.i18nKey : null;
|
|
59
60
|
|
|
60
|
-
const
|
|
61
|
-
const
|
|
61
|
+
const isAuthStatus = status === 401 || status === 403;
|
|
62
|
+
const isNotAuthenticated =
|
|
63
|
+
code === "not_authenticated" || i18nKey === "auth.not_authenticated";
|
|
62
64
|
|
|
63
|
-
if (
|
|
65
|
+
if (isAuthStatus && isNotAuthenticated) {
|
|
64
66
|
redirectToLoginOnce();
|
|
65
67
|
}
|
|
66
68
|
return Promise.reject(error);
|
|
@@ -87,4 +89,4 @@ export async function ensureCsrfToken() {
|
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
|
|
90
|
-
export default apiClient;
|
|
92
|
+
export default apiClient;
|