@qlibs/utils 1.9.0 → 1.10.0
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/utils/auth.d.ts +2 -2
- package/dist/utils/auth.js +11 -2
- package/dist/utils/errorHandler.js +13 -1
- package/package.json +1 -1
package/dist/utils/auth.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export declare function saveToken(token: string): void;
|
2
2
|
export declare function getToken(): string;
|
3
3
|
export declare function removeToken(): void;
|
4
|
-
export declare function saveUserData(userData:
|
5
|
-
export declare function getUserData():
|
4
|
+
export declare function saveUserData(userData: object): void;
|
5
|
+
export declare function getUserData(): any;
|
6
6
|
export declare function removeUserData(): void;
|
package/dist/utils/auth.js
CHANGED
@@ -18,10 +18,19 @@ function removeToken() {
|
|
18
18
|
return localStorage.removeItem(APP_AUTH_TOKEN);
|
19
19
|
}
|
20
20
|
function saveUserData(userData) {
|
21
|
-
return localStorage.setItem(APP_AUTH_USER_DATA, userData);
|
21
|
+
return localStorage.setItem(APP_AUTH_USER_DATA, JSON.stringify(userData));
|
22
22
|
}
|
23
23
|
function getUserData() {
|
24
|
-
|
24
|
+
const userData = localStorage.getItem(APP_AUTH_USER_DATA);
|
25
|
+
try {
|
26
|
+
if (userData) {
|
27
|
+
return JSON.parse(userData);
|
28
|
+
}
|
29
|
+
return null;
|
30
|
+
}
|
31
|
+
catch (error) {
|
32
|
+
return null;
|
33
|
+
}
|
25
34
|
}
|
26
35
|
function removeUserData() {
|
27
36
|
return localStorage.removeItem(APP_AUTH_USER_DATA);
|
@@ -117,7 +117,19 @@ function getStandardError(err, config) {
|
|
117
117
|
handleFormValidation(errors || [], config.formRef);
|
118
118
|
}
|
119
119
|
if ((config === null || config === void 0 ? void 0 : config.showToast) && (config === null || config === void 0 ? void 0 : config.toastFunction)) {
|
120
|
-
config.toastFunction.
|
120
|
+
if (config.toastFunction.confirm) {
|
121
|
+
config.toastFunction.error({
|
122
|
+
title: 'Failed',
|
123
|
+
content: message,
|
124
|
+
closable: true,
|
125
|
+
});
|
126
|
+
}
|
127
|
+
else if (config.toastFunction.error) {
|
128
|
+
config.toastFunction.error(message);
|
129
|
+
}
|
130
|
+
else if (typeof config.toastFunction === 'function') {
|
131
|
+
config.toastFunction(message);
|
132
|
+
}
|
121
133
|
}
|
122
134
|
return {
|
123
135
|
code,
|