@etsoo/materialui 1.4.53 → 1.4.54
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 +1 -1
- package/lib/app/ServiceApp.js +8 -1
- package/package.json +1 -1
- package/src/app/ServiceApp.ts +11 -1
package/lib/app/ServiceApp.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
73
73
|
* @param fromOrganizationId From organization ID
|
|
74
74
|
* @param payload Payload
|
|
75
75
|
*/
|
|
76
|
-
switchOrg(organizationId: number, fromOrganizationId?: number, payload?: IApiPayload<IActionResult<U & ServiceUserToken>>): Promise<
|
|
76
|
+
switchOrg(organizationId: number, fromOrganizationId?: number, payload?: IApiPayload<IActionResult<U & ServiceUserToken>>): Promise<IActionResult<U & ServiceUserToken> | undefined>;
|
|
77
77
|
/**
|
|
78
78
|
* Try login
|
|
79
79
|
* @param params Login parameters
|
package/lib/app/ServiceApp.js
CHANGED
|
@@ -168,8 +168,14 @@ export class ServiceApp extends ReactApp {
|
|
|
168
168
|
throw new Error("Core access token is required to switch organization.");
|
|
169
169
|
}
|
|
170
170
|
const [result, refreshToken] = await new AuthApi(this, this.coreApi).switchOrg({ organizationId, fromOrganizationId, token: this.coreAccessToken }, payload);
|
|
171
|
-
if (result == null
|
|
171
|
+
if (result == null)
|
|
172
172
|
return;
|
|
173
|
+
if (!result.ok) {
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
if (result.data == null) {
|
|
177
|
+
throw new Error("Invalid switch organization result.");
|
|
178
|
+
}
|
|
173
179
|
let core;
|
|
174
180
|
if ("core" in result.data && typeof result.data.core === "string") {
|
|
175
181
|
core = JSON.parse(result.data.core);
|
|
@@ -179,6 +185,7 @@ export class ServiceApp extends ReactApp {
|
|
|
179
185
|
const user = refreshToken ? { ...result.data, refreshToken } : result.data;
|
|
180
186
|
// User login
|
|
181
187
|
this.userLoginEx(user, core, true);
|
|
188
|
+
return result;
|
|
182
189
|
}
|
|
183
190
|
/**
|
|
184
191
|
* Try login
|
package/package.json
CHANGED
package/src/app/ServiceApp.ts
CHANGED
|
@@ -228,7 +228,15 @@ export class ServiceApp<
|
|
|
228
228
|
payload
|
|
229
229
|
);
|
|
230
230
|
|
|
231
|
-
if (result == null
|
|
231
|
+
if (result == null) return;
|
|
232
|
+
|
|
233
|
+
if (!result.ok) {
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (result.data == null) {
|
|
238
|
+
throw new Error("Invalid switch organization result.");
|
|
239
|
+
}
|
|
232
240
|
|
|
233
241
|
let core: ApiRefreshTokenDto | undefined;
|
|
234
242
|
if ("core" in result.data && typeof result.data.core === "string") {
|
|
@@ -241,6 +249,8 @@ export class ServiceApp<
|
|
|
241
249
|
|
|
242
250
|
// User login
|
|
243
251
|
this.userLoginEx(user, core, true);
|
|
252
|
+
|
|
253
|
+
return result;
|
|
244
254
|
}
|
|
245
255
|
|
|
246
256
|
/**
|