@etsoo/materialui 1.4.8 → 1.4.10
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/lib/app/CommonApp.js +1 -1
- package/lib/app/ServiceApp.d.ts +5 -0
- package/lib/app/ServiceApp.js +17 -4
- package/package.json +6 -6
- package/src/app/CommonApp.ts +1 -1
- package/src/app/ServiceApp.ts +21 -4
package/lib/app/CommonApp.js
CHANGED
package/lib/app/ServiceApp.d.ts
CHANGED
|
@@ -54,6 +54,11 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
54
54
|
* @param dispatch User state dispatch
|
|
55
55
|
*/
|
|
56
56
|
userLoginEx(user: U & ServiceUserToken, core?: ApiRefreshTokenDto, dispatch?: boolean): void;
|
|
57
|
+
/**
|
|
58
|
+
* Save core system refresh token
|
|
59
|
+
* @param token New refresh token
|
|
60
|
+
*/
|
|
61
|
+
protected saveCoreToken(token: string): void;
|
|
57
62
|
/**
|
|
58
63
|
* Try login
|
|
59
64
|
* @param params Login parameters
|
package/lib/app/ServiceApp.js
CHANGED
|
@@ -110,25 +110,38 @@ export class ServiceApp extends ReactApp {
|
|
|
110
110
|
expiresIn: user.seconds
|
|
111
111
|
});
|
|
112
112
|
// Cache the core system refresh token
|
|
113
|
-
this.
|
|
113
|
+
this.saveCoreToken(core.refreshToken);
|
|
114
114
|
this.exchangeTokenAll(core, coreName);
|
|
115
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Save core system refresh token
|
|
118
|
+
* @param token New refresh token
|
|
119
|
+
*/
|
|
120
|
+
saveCoreToken(token) {
|
|
121
|
+
this.storage.setData(coreTokenKey, this.encrypt(token));
|
|
122
|
+
}
|
|
116
123
|
/**
|
|
117
124
|
* Try login
|
|
118
125
|
* @param params Login parameters
|
|
119
126
|
*/
|
|
120
127
|
async tryLogin(params) {
|
|
128
|
+
// Current callback
|
|
129
|
+
params ?? (params = {});
|
|
130
|
+
const onSuccess = params.onSuccess;
|
|
131
|
+
const onFailure = params.onFailure;
|
|
121
132
|
// Check core system token
|
|
122
133
|
const coreToken = this.storage.getData(coreTokenKey);
|
|
123
|
-
if (!coreToken)
|
|
134
|
+
if (!coreToken) {
|
|
135
|
+
onFailure?.();
|
|
124
136
|
return false;
|
|
125
|
-
|
|
126
|
-
const onSuccess = params.onSuccess;
|
|
137
|
+
}
|
|
127
138
|
params.onSuccess = () => {
|
|
128
139
|
// Call the core system API refresh token
|
|
129
140
|
this.apiRefreshTokenData(this.coreApi, coreToken).then((data) => {
|
|
130
141
|
if (data == null)
|
|
131
142
|
return;
|
|
143
|
+
// Cache the core system refresh token
|
|
144
|
+
this.saveCoreToken(data.refreshToken);
|
|
132
145
|
this.exchangeTokenAll(data, coreName);
|
|
133
146
|
onSuccess?.();
|
|
134
147
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.10",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"@emotion/css": "^11.13.4",
|
|
51
51
|
"@emotion/react": "^11.13.3",
|
|
52
52
|
"@emotion/styled": "^11.13.0",
|
|
53
|
-
"@etsoo/appscript": "^1.5.
|
|
54
|
-
"@etsoo/notificationbase": "^1.1.
|
|
55
|
-
"@etsoo/react": "^1.7.
|
|
56
|
-
"@etsoo/shared": "^1.2.
|
|
53
|
+
"@etsoo/appscript": "^1.5.52",
|
|
54
|
+
"@etsoo/notificationbase": "^1.1.50",
|
|
55
|
+
"@etsoo/react": "^1.7.85",
|
|
56
|
+
"@etsoo/shared": "^1.2.49",
|
|
57
57
|
"@mui/icons-material": "^6.1.4",
|
|
58
58
|
"@mui/material": "^6.1.4",
|
|
59
59
|
"@mui/x-data-grid": "^7.20.0",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@babel/preset-react": "^7.25.7",
|
|
78
78
|
"@babel/preset-typescript": "^7.25.7",
|
|
79
79
|
"@babel/runtime-corejs3": "^7.25.7",
|
|
80
|
-
"@testing-library/jest-dom": "^6.
|
|
80
|
+
"@testing-library/jest-dom": "^6.6.1",
|
|
81
81
|
"@testing-library/react": "^16.0.1",
|
|
82
82
|
"@types/jest": "^29.5.13",
|
|
83
83
|
"@types/pica": "^9.0.4",
|
package/src/app/CommonApp.ts
CHANGED
package/src/app/ServiceApp.ts
CHANGED
|
@@ -162,27 +162,44 @@ export class ServiceApp<
|
|
|
162
162
|
};
|
|
163
163
|
|
|
164
164
|
// Cache the core system refresh token
|
|
165
|
-
this.
|
|
165
|
+
this.saveCoreToken(core.refreshToken);
|
|
166
166
|
|
|
167
167
|
this.exchangeTokenAll(core, coreName);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Save core system refresh token
|
|
172
|
+
* @param token New refresh token
|
|
173
|
+
*/
|
|
174
|
+
protected saveCoreToken(token: string) {
|
|
175
|
+
this.storage.setData(coreTokenKey, this.encrypt(token));
|
|
176
|
+
}
|
|
177
|
+
|
|
170
178
|
/**
|
|
171
179
|
* Try login
|
|
172
180
|
* @param params Login parameters
|
|
173
181
|
*/
|
|
174
182
|
override async tryLogin(params?: AppTryLoginParams) {
|
|
183
|
+
// Current callback
|
|
184
|
+
params ??= {};
|
|
185
|
+
const onSuccess = params.onSuccess;
|
|
186
|
+
const onFailure = params.onFailure;
|
|
187
|
+
|
|
175
188
|
// Check core system token
|
|
176
189
|
const coreToken = this.storage.getData<string>(coreTokenKey);
|
|
177
|
-
if (!coreToken)
|
|
190
|
+
if (!coreToken) {
|
|
191
|
+
onFailure?.();
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
178
194
|
|
|
179
|
-
params ??= {};
|
|
180
|
-
const onSuccess = params.onSuccess;
|
|
181
195
|
params.onSuccess = () => {
|
|
182
196
|
// Call the core system API refresh token
|
|
183
197
|
this.apiRefreshTokenData(this.coreApi, coreToken).then((data) => {
|
|
184
198
|
if (data == null) return;
|
|
185
199
|
|
|
200
|
+
// Cache the core system refresh token
|
|
201
|
+
this.saveCoreToken(data.refreshToken);
|
|
202
|
+
|
|
186
203
|
this.exchangeTokenAll(data, coreName);
|
|
187
204
|
|
|
188
205
|
onSuccess?.();
|