@etsoo/materialui 1.4.10 → 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.
@@ -125,14 +125,18 @@ export class ServiceApp extends ReactApp {
125
125
  * @param params Login parameters
126
126
  */
127
127
  async tryLogin(params) {
128
- // Current callback
128
+ // Destruct
129
129
  params ?? (params = {});
130
- const onSuccess = params.onSuccess;
131
- const onFailure = params.onFailure;
130
+ let { onFailure, onSuccess, ...rest } = params;
131
+ if (onFailure == null) {
132
+ onFailure = params.onFailure = () => {
133
+ this.toLoginPage(rest);
134
+ };
135
+ }
132
136
  // Check core system token
133
137
  const coreToken = this.storage.getData(coreTokenKey);
134
138
  if (!coreToken) {
135
- onFailure?.();
139
+ onFailure();
136
140
  return false;
137
141
  }
138
142
  params.onSuccess = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.4.10",
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",
@@ -180,15 +180,20 @@ export class ServiceApp<
180
180
  * @param params Login parameters
181
181
  */
182
182
  override async tryLogin(params?: AppTryLoginParams) {
183
- // Current callback
183
+ // Destruct
184
184
  params ??= {};
185
- const onSuccess = params.onSuccess;
186
- const onFailure = params.onFailure;
185
+ let { onFailure, onSuccess, ...rest } = params;
186
+
187
+ if (onFailure == null) {
188
+ onFailure = params.onFailure = () => {
189
+ this.toLoginPage(rest);
190
+ };
191
+ }
187
192
 
188
193
  // Check core system token
189
194
  const coreToken = this.storage.getData<string>(coreTokenKey);
190
195
  if (!coreToken) {
191
- onFailure?.();
196
+ onFailure();
192
197
  return false;
193
198
  }
194
199
 
@@ -205,6 +210,7 @@ export class ServiceApp<
205
210
  onSuccess?.();
206
211
  });
207
212
  };
213
+
208
214
  return await super.tryLogin(params);
209
215
  }
210
216
  }