@etsoo/materialui 1.4.8 → 1.4.9

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.
@@ -42,7 +42,7 @@ export class CommonApp extends ReactApp {
42
42
  if (result === true) {
43
43
  onSuccess?.();
44
44
  }
45
- else {
45
+ else if (result === false) {
46
46
  onFailure();
47
47
  }
48
48
  });
@@ -118,17 +118,23 @@ export class ServiceApp extends ReactApp {
118
118
  * @param params Login parameters
119
119
  */
120
120
  async tryLogin(params) {
121
+ // Current callback
122
+ params ?? (params = {});
123
+ const onSuccess = params.onSuccess;
124
+ const onFailure = params.onFailure;
121
125
  // Check core system token
122
126
  const coreToken = this.storage.getData(coreTokenKey);
123
- if (!coreToken)
127
+ if (!coreToken) {
128
+ onFailure?.();
124
129
  return false;
125
- params ?? (params = {});
126
- const onSuccess = params.onSuccess;
130
+ }
127
131
  params.onSuccess = () => {
128
132
  // Call the core system API refresh token
129
133
  this.apiRefreshTokenData(this.coreApi, coreToken).then((data) => {
130
134
  if (data == null)
131
135
  return;
136
+ // Cache the core system refresh token
137
+ this.storage.setData(coreTokenKey, data.refreshToken);
132
138
  this.exchangeTokenAll(data, coreName);
133
139
  onSuccess?.();
134
140
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.4.8",
3
+ "version": "1.4.9",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -57,7 +57,7 @@ export abstract class CommonApp<
57
57
  (result) => {
58
58
  if (result === true) {
59
59
  onSuccess?.();
60
- } else {
60
+ } else if (result === false) {
61
61
  onFailure();
62
62
  }
63
63
  }
@@ -172,17 +172,26 @@ export class ServiceApp<
172
172
  * @param params Login parameters
173
173
  */
174
174
  override async tryLogin(params?: AppTryLoginParams) {
175
+ // Current callback
176
+ params ??= {};
177
+ const onSuccess = params.onSuccess;
178
+ const onFailure = params.onFailure;
179
+
175
180
  // Check core system token
176
181
  const coreToken = this.storage.getData<string>(coreTokenKey);
177
- if (!coreToken) return false;
182
+ if (!coreToken) {
183
+ onFailure?.();
184
+ return false;
185
+ }
178
186
 
179
- params ??= {};
180
- const onSuccess = params.onSuccess;
181
187
  params.onSuccess = () => {
182
188
  // Call the core system API refresh token
183
189
  this.apiRefreshTokenData(this.coreApi, coreToken).then((data) => {
184
190
  if (data == null) return;
185
191
 
192
+ // Cache the core system refresh token
193
+ this.storage.setData(coreTokenKey, data.refreshToken);
194
+
186
195
  this.exchangeTokenAll(data, coreName);
187
196
 
188
197
  onSuccess?.();