@etsoo/materialui 1.4.9 → 1.4.11
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/ServiceApp.d.ts +5 -0
- package/lib/app/ServiceApp.js +17 -6
- package/package.json +6 -6
- package/src/app/ServiceApp.ts +20 -6
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,22 +110,33 @@ 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) {
|
|
121
|
-
//
|
|
128
|
+
// Destruct
|
|
122
129
|
params ?? (params = {});
|
|
123
|
-
|
|
124
|
-
|
|
130
|
+
let { onFailure, onSuccess, ...rest } = params;
|
|
131
|
+
if (onFailure == null) {
|
|
132
|
+
onFailure = params.onFailure = () => {
|
|
133
|
+
this.toLoginPage(rest);
|
|
134
|
+
};
|
|
135
|
+
}
|
|
125
136
|
// Check core system token
|
|
126
137
|
const coreToken = this.storage.getData(coreTokenKey);
|
|
127
138
|
if (!coreToken) {
|
|
128
|
-
onFailure
|
|
139
|
+
onFailure();
|
|
129
140
|
return false;
|
|
130
141
|
}
|
|
131
142
|
params.onSuccess = () => {
|
|
@@ -134,7 +145,7 @@ export class ServiceApp extends ReactApp {
|
|
|
134
145
|
if (data == null)
|
|
135
146
|
return;
|
|
136
147
|
// Cache the core system refresh token
|
|
137
|
-
this.
|
|
148
|
+
this.saveCoreToken(data.refreshToken);
|
|
138
149
|
this.exchangeTokenAll(data, coreName);
|
|
139
150
|
onSuccess?.();
|
|
140
151
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.11",
|
|
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/ServiceApp.ts
CHANGED
|
@@ -162,25 +162,38 @@ 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) {
|
|
175
|
-
//
|
|
183
|
+
// Destruct
|
|
176
184
|
params ??= {};
|
|
177
|
-
|
|
178
|
-
|
|
185
|
+
let { onFailure, onSuccess, ...rest } = params;
|
|
186
|
+
|
|
187
|
+
if (onFailure == null) {
|
|
188
|
+
onFailure = params.onFailure = () => {
|
|
189
|
+
this.toLoginPage(rest);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
179
192
|
|
|
180
193
|
// Check core system token
|
|
181
194
|
const coreToken = this.storage.getData<string>(coreTokenKey);
|
|
182
195
|
if (!coreToken) {
|
|
183
|
-
onFailure
|
|
196
|
+
onFailure();
|
|
184
197
|
return false;
|
|
185
198
|
}
|
|
186
199
|
|
|
@@ -190,13 +203,14 @@ export class ServiceApp<
|
|
|
190
203
|
if (data == null) return;
|
|
191
204
|
|
|
192
205
|
// Cache the core system refresh token
|
|
193
|
-
this.
|
|
206
|
+
this.saveCoreToken(data.refreshToken);
|
|
194
207
|
|
|
195
208
|
this.exchangeTokenAll(data, coreName);
|
|
196
209
|
|
|
197
210
|
onSuccess?.();
|
|
198
211
|
});
|
|
199
212
|
};
|
|
213
|
+
|
|
200
214
|
return await super.tryLogin(params);
|
|
201
215
|
}
|
|
202
216
|
}
|