@etsoo/appscript 1.1.87 → 1.1.91
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/cjs/app/CoreApp.d.ts +18 -8
- package/lib/cjs/app/CoreApp.js +37 -7
- package/lib/mjs/app/CoreApp.d.ts +18 -8
- package/lib/mjs/app/CoreApp.js +37 -7
- package/package.json +1 -1
- package/src/app/CoreApp.ts +61 -21
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -280,9 +280,8 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
280
280
|
refreshToken<D extends {} = {}>(props?: RefreshTokenProps<D>): Promise<boolean>;
|
|
281
281
|
/**
|
|
282
282
|
* Signout
|
|
283
|
-
* @param apiUrl Signout API URL
|
|
284
283
|
*/
|
|
285
|
-
signout(
|
|
284
|
+
signout(): Promise<void>;
|
|
286
285
|
/**
|
|
287
286
|
* Get organization list
|
|
288
287
|
* @param items Max items
|
|
@@ -292,9 +291,10 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
292
291
|
orgList(items?: number, serviceId?: number): Promise<IdLabelDto[] | undefined>;
|
|
293
292
|
/**
|
|
294
293
|
* Switch organization
|
|
295
|
-
* @param
|
|
294
|
+
* @param id Organization id
|
|
295
|
+
* @param serviceId Service id
|
|
296
296
|
*/
|
|
297
|
-
switchOrg(
|
|
297
|
+
switchOrg(id: number, serviceId?: number): Promise<boolean | undefined>;
|
|
298
298
|
/**
|
|
299
299
|
* Go to the login page
|
|
300
300
|
*/
|
|
@@ -422,11 +422,15 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
422
422
|
/**
|
|
423
423
|
* Device id field name
|
|
424
424
|
*/
|
|
425
|
-
|
|
425
|
+
private readonly deviceIdField;
|
|
426
|
+
/**
|
|
427
|
+
* Device passphrase field name
|
|
428
|
+
*/
|
|
429
|
+
private readonly devicePassphraseField;
|
|
426
430
|
/**
|
|
427
431
|
* Device id update time field name
|
|
428
432
|
*/
|
|
429
|
-
|
|
433
|
+
private readonly deviceIdUpdateTimeField;
|
|
430
434
|
/**
|
|
431
435
|
* Init call Api URL
|
|
432
436
|
*/
|
|
@@ -445,6 +449,11 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
445
449
|
*/
|
|
446
450
|
protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, name: string);
|
|
447
451
|
protected setApi(api: IApi): void;
|
|
452
|
+
/**
|
|
453
|
+
* Setup device
|
|
454
|
+
* @returns Device id
|
|
455
|
+
*/
|
|
456
|
+
protected setupDevice(): string;
|
|
448
457
|
/**
|
|
449
458
|
* Api init call
|
|
450
459
|
* @param data Data
|
|
@@ -669,7 +678,7 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
669
678
|
* Signout
|
|
670
679
|
* @param apiUrl Signout API URL
|
|
671
680
|
*/
|
|
672
|
-
signout(
|
|
681
|
+
signout(): Promise<void>;
|
|
673
682
|
/**
|
|
674
683
|
* Get organization list
|
|
675
684
|
* @param items Max items
|
|
@@ -680,8 +689,9 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
680
689
|
/**
|
|
681
690
|
* Switch organization
|
|
682
691
|
* @param id Organization id
|
|
692
|
+
* @param serviceId Service id
|
|
683
693
|
*/
|
|
684
|
-
switchOrg(id: number): Promise<boolean | undefined>;
|
|
694
|
+
switchOrg(id: number, serviceId?: number): Promise<boolean | undefined>;
|
|
685
695
|
/**
|
|
686
696
|
* Go to the login page
|
|
687
697
|
*/
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -43,6 +43,10 @@ class CoreApp {
|
|
|
43
43
|
* Device id field name
|
|
44
44
|
*/
|
|
45
45
|
this.deviceIdField = 'SmartERPDeviceId';
|
|
46
|
+
/**
|
|
47
|
+
* Device passphrase field name
|
|
48
|
+
*/
|
|
49
|
+
this.devicePassphraseField = 'SmartERPDevicePassphrase';
|
|
46
50
|
/**
|
|
47
51
|
* Device id update time field name
|
|
48
52
|
*/
|
|
@@ -59,7 +63,7 @@ class CoreApp {
|
|
|
59
63
|
this.api = api;
|
|
60
64
|
this.notifier = notifier;
|
|
61
65
|
this.name = name;
|
|
62
|
-
this.deviceId =
|
|
66
|
+
this.deviceId = this.setupDevice();
|
|
63
67
|
this.setApi(api);
|
|
64
68
|
const { currentCulture, currentRegion } = settings;
|
|
65
69
|
this.changeCulture(currentCulture);
|
|
@@ -157,6 +161,25 @@ class CoreApp {
|
|
|
157
161
|
}
|
|
158
162
|
};
|
|
159
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Setup device
|
|
166
|
+
* @returns Device id
|
|
167
|
+
*/
|
|
168
|
+
setupDevice() {
|
|
169
|
+
const deviceId = shared_1.StorageUtils.getLocalData(this.deviceIdField);
|
|
170
|
+
if (deviceId != null && deviceId !== '') {
|
|
171
|
+
const passphraseEncrypted = shared_1.StorageUtils.getLocalData(this.devicePassphraseField);
|
|
172
|
+
if (passphraseEncrypted != null && passphraseEncrypted !== '') {
|
|
173
|
+
const timestamp = this.getDeviceUpdateTime();
|
|
174
|
+
if (timestamp > 0) {
|
|
175
|
+
const passphraseDecrypted = this.decrypt(passphraseEncrypted, timestamp.toString());
|
|
176
|
+
if (passphraseDecrypted != null)
|
|
177
|
+
this.passphrase = passphraseDecrypted;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return deviceId !== null && deviceId !== void 0 ? deviceId : '';
|
|
182
|
+
}
|
|
160
183
|
/**
|
|
161
184
|
* Api init call
|
|
162
185
|
* @param data Data
|
|
@@ -248,6 +271,7 @@ class CoreApp {
|
|
|
248
271
|
// Update device id and cache it
|
|
249
272
|
this.deviceId = data.deviceId;
|
|
250
273
|
shared_1.StorageUtils.setLocalData(this.deviceIdField, this.deviceId);
|
|
274
|
+
shared_1.StorageUtils.setLocalData(this.devicePassphraseField, data.passphrase);
|
|
251
275
|
shared_1.StorageUtils.setLocalData(this.deviceIdUpdateTimeField, timestamp);
|
|
252
276
|
// Current passphrase
|
|
253
277
|
this.passphrase = passphrase;
|
|
@@ -380,6 +404,7 @@ class CoreApp {
|
|
|
380
404
|
clearCacheData() {
|
|
381
405
|
shared_1.StorageUtils.setLocalData(this.serversideDeviceIdField, undefined);
|
|
382
406
|
shared_1.StorageUtils.setLocalData(this.deviceIdField, undefined);
|
|
407
|
+
shared_1.StorageUtils.setLocalData(this.devicePassphraseField, undefined);
|
|
383
408
|
shared_1.StorageUtils.setLocalData(this.deviceIdUpdateTimeField, undefined);
|
|
384
409
|
shared_1.StorageUtils.setLocalData(this.headerTokenField, undefined);
|
|
385
410
|
}
|
|
@@ -765,8 +790,8 @@ class CoreApp {
|
|
|
765
790
|
* Signout
|
|
766
791
|
* @param apiUrl Signout API URL
|
|
767
792
|
*/
|
|
768
|
-
async signout(
|
|
769
|
-
await this.api.put(
|
|
793
|
+
async signout() {
|
|
794
|
+
await this.api.put('User/Signout', { deviceId: this.deviceId }, {
|
|
770
795
|
onError: (error) => {
|
|
771
796
|
console.log(error);
|
|
772
797
|
// Prevent further processing
|
|
@@ -793,10 +818,15 @@ class CoreApp {
|
|
|
793
818
|
/**
|
|
794
819
|
* Switch organization
|
|
795
820
|
* @param id Organization id
|
|
821
|
+
* @param serviceId Service id
|
|
796
822
|
*/
|
|
797
|
-
async switchOrg(id) {
|
|
798
|
-
const api = `Organization/Switch
|
|
799
|
-
const result = await this.api.put(api
|
|
823
|
+
async switchOrg(id, serviceId) {
|
|
824
|
+
const api = `Organization/Switch`;
|
|
825
|
+
const result = await this.api.put(api, {
|
|
826
|
+
id,
|
|
827
|
+
serviceId,
|
|
828
|
+
deviceId: this.deviceId
|
|
829
|
+
});
|
|
800
830
|
if (result)
|
|
801
831
|
return await this.refreshToken();
|
|
802
832
|
return result;
|
|
@@ -854,7 +884,7 @@ class CoreApp {
|
|
|
854
884
|
this.authorize(user.token, refreshToken);
|
|
855
885
|
}
|
|
856
886
|
else {
|
|
857
|
-
this.cachedRefreshToken = refreshToken;
|
|
887
|
+
this.cachedRefreshToken = this.encrypt(refreshToken);
|
|
858
888
|
this.authorize(user.token, undefined);
|
|
859
889
|
}
|
|
860
890
|
}
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -280,9 +280,8 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
280
280
|
refreshToken<D extends {} = {}>(props?: RefreshTokenProps<D>): Promise<boolean>;
|
|
281
281
|
/**
|
|
282
282
|
* Signout
|
|
283
|
-
* @param apiUrl Signout API URL
|
|
284
283
|
*/
|
|
285
|
-
signout(
|
|
284
|
+
signout(): Promise<void>;
|
|
286
285
|
/**
|
|
287
286
|
* Get organization list
|
|
288
287
|
* @param items Max items
|
|
@@ -292,9 +291,10 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
292
291
|
orgList(items?: number, serviceId?: number): Promise<IdLabelDto[] | undefined>;
|
|
293
292
|
/**
|
|
294
293
|
* Switch organization
|
|
295
|
-
* @param
|
|
294
|
+
* @param id Organization id
|
|
295
|
+
* @param serviceId Service id
|
|
296
296
|
*/
|
|
297
|
-
switchOrg(
|
|
297
|
+
switchOrg(id: number, serviceId?: number): Promise<boolean | undefined>;
|
|
298
298
|
/**
|
|
299
299
|
* Go to the login page
|
|
300
300
|
*/
|
|
@@ -422,11 +422,15 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
422
422
|
/**
|
|
423
423
|
* Device id field name
|
|
424
424
|
*/
|
|
425
|
-
|
|
425
|
+
private readonly deviceIdField;
|
|
426
|
+
/**
|
|
427
|
+
* Device passphrase field name
|
|
428
|
+
*/
|
|
429
|
+
private readonly devicePassphraseField;
|
|
426
430
|
/**
|
|
427
431
|
* Device id update time field name
|
|
428
432
|
*/
|
|
429
|
-
|
|
433
|
+
private readonly deviceIdUpdateTimeField;
|
|
430
434
|
/**
|
|
431
435
|
* Init call Api URL
|
|
432
436
|
*/
|
|
@@ -445,6 +449,11 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
445
449
|
*/
|
|
446
450
|
protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, name: string);
|
|
447
451
|
protected setApi(api: IApi): void;
|
|
452
|
+
/**
|
|
453
|
+
* Setup device
|
|
454
|
+
* @returns Device id
|
|
455
|
+
*/
|
|
456
|
+
protected setupDevice(): string;
|
|
448
457
|
/**
|
|
449
458
|
* Api init call
|
|
450
459
|
* @param data Data
|
|
@@ -669,7 +678,7 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
669
678
|
* Signout
|
|
670
679
|
* @param apiUrl Signout API URL
|
|
671
680
|
*/
|
|
672
|
-
signout(
|
|
681
|
+
signout(): Promise<void>;
|
|
673
682
|
/**
|
|
674
683
|
* Get organization list
|
|
675
684
|
* @param items Max items
|
|
@@ -680,8 +689,9 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
680
689
|
/**
|
|
681
690
|
* Switch organization
|
|
682
691
|
* @param id Organization id
|
|
692
|
+
* @param serviceId Service id
|
|
683
693
|
*/
|
|
684
|
-
switchOrg(id: number): Promise<boolean | undefined>;
|
|
694
|
+
switchOrg(id: number, serviceId?: number): Promise<boolean | undefined>;
|
|
685
695
|
/**
|
|
686
696
|
* Go to the login page
|
|
687
697
|
*/
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -40,6 +40,10 @@ export class CoreApp {
|
|
|
40
40
|
* Device id field name
|
|
41
41
|
*/
|
|
42
42
|
this.deviceIdField = 'SmartERPDeviceId';
|
|
43
|
+
/**
|
|
44
|
+
* Device passphrase field name
|
|
45
|
+
*/
|
|
46
|
+
this.devicePassphraseField = 'SmartERPDevicePassphrase';
|
|
43
47
|
/**
|
|
44
48
|
* Device id update time field name
|
|
45
49
|
*/
|
|
@@ -56,7 +60,7 @@ export class CoreApp {
|
|
|
56
60
|
this.api = api;
|
|
57
61
|
this.notifier = notifier;
|
|
58
62
|
this.name = name;
|
|
59
|
-
this.deviceId =
|
|
63
|
+
this.deviceId = this.setupDevice();
|
|
60
64
|
this.setApi(api);
|
|
61
65
|
const { currentCulture, currentRegion } = settings;
|
|
62
66
|
this.changeCulture(currentCulture);
|
|
@@ -154,6 +158,25 @@ export class CoreApp {
|
|
|
154
158
|
}
|
|
155
159
|
};
|
|
156
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Setup device
|
|
163
|
+
* @returns Device id
|
|
164
|
+
*/
|
|
165
|
+
setupDevice() {
|
|
166
|
+
const deviceId = StorageUtils.getLocalData(this.deviceIdField);
|
|
167
|
+
if (deviceId != null && deviceId !== '') {
|
|
168
|
+
const passphraseEncrypted = StorageUtils.getLocalData(this.devicePassphraseField);
|
|
169
|
+
if (passphraseEncrypted != null && passphraseEncrypted !== '') {
|
|
170
|
+
const timestamp = this.getDeviceUpdateTime();
|
|
171
|
+
if (timestamp > 0) {
|
|
172
|
+
const passphraseDecrypted = this.decrypt(passphraseEncrypted, timestamp.toString());
|
|
173
|
+
if (passphraseDecrypted != null)
|
|
174
|
+
this.passphrase = passphraseDecrypted;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return deviceId !== null && deviceId !== void 0 ? deviceId : '';
|
|
179
|
+
}
|
|
157
180
|
/**
|
|
158
181
|
* Api init call
|
|
159
182
|
* @param data Data
|
|
@@ -245,6 +268,7 @@ export class CoreApp {
|
|
|
245
268
|
// Update device id and cache it
|
|
246
269
|
this.deviceId = data.deviceId;
|
|
247
270
|
StorageUtils.setLocalData(this.deviceIdField, this.deviceId);
|
|
271
|
+
StorageUtils.setLocalData(this.devicePassphraseField, data.passphrase);
|
|
248
272
|
StorageUtils.setLocalData(this.deviceIdUpdateTimeField, timestamp);
|
|
249
273
|
// Current passphrase
|
|
250
274
|
this.passphrase = passphrase;
|
|
@@ -377,6 +401,7 @@ export class CoreApp {
|
|
|
377
401
|
clearCacheData() {
|
|
378
402
|
StorageUtils.setLocalData(this.serversideDeviceIdField, undefined);
|
|
379
403
|
StorageUtils.setLocalData(this.deviceIdField, undefined);
|
|
404
|
+
StorageUtils.setLocalData(this.devicePassphraseField, undefined);
|
|
380
405
|
StorageUtils.setLocalData(this.deviceIdUpdateTimeField, undefined);
|
|
381
406
|
StorageUtils.setLocalData(this.headerTokenField, undefined);
|
|
382
407
|
}
|
|
@@ -762,8 +787,8 @@ export class CoreApp {
|
|
|
762
787
|
* Signout
|
|
763
788
|
* @param apiUrl Signout API URL
|
|
764
789
|
*/
|
|
765
|
-
async signout(
|
|
766
|
-
await this.api.put(
|
|
790
|
+
async signout() {
|
|
791
|
+
await this.api.put('User/Signout', { deviceId: this.deviceId }, {
|
|
767
792
|
onError: (error) => {
|
|
768
793
|
console.log(error);
|
|
769
794
|
// Prevent further processing
|
|
@@ -790,10 +815,15 @@ export class CoreApp {
|
|
|
790
815
|
/**
|
|
791
816
|
* Switch organization
|
|
792
817
|
* @param id Organization id
|
|
818
|
+
* @param serviceId Service id
|
|
793
819
|
*/
|
|
794
|
-
async switchOrg(id) {
|
|
795
|
-
const api = `Organization/Switch
|
|
796
|
-
const result = await this.api.put(api
|
|
820
|
+
async switchOrg(id, serviceId) {
|
|
821
|
+
const api = `Organization/Switch`;
|
|
822
|
+
const result = await this.api.put(api, {
|
|
823
|
+
id,
|
|
824
|
+
serviceId,
|
|
825
|
+
deviceId: this.deviceId
|
|
826
|
+
});
|
|
797
827
|
if (result)
|
|
798
828
|
return await this.refreshToken();
|
|
799
829
|
return result;
|
|
@@ -851,7 +881,7 @@ export class CoreApp {
|
|
|
851
881
|
this.authorize(user.token, refreshToken);
|
|
852
882
|
}
|
|
853
883
|
else {
|
|
854
|
-
this.cachedRefreshToken = refreshToken;
|
|
884
|
+
this.cachedRefreshToken = this.encrypt(refreshToken);
|
|
855
885
|
this.authorize(user.token, undefined);
|
|
856
886
|
}
|
|
857
887
|
}
|
package/package.json
CHANGED
package/src/app/CoreApp.ts
CHANGED
|
@@ -384,9 +384,8 @@ export interface ICoreApp<
|
|
|
384
384
|
|
|
385
385
|
/**
|
|
386
386
|
* Signout
|
|
387
|
-
* @param apiUrl Signout API URL
|
|
388
387
|
*/
|
|
389
|
-
signout(
|
|
388
|
+
signout(): Promise<void>;
|
|
390
389
|
|
|
391
390
|
/**
|
|
392
391
|
* Get organization list
|
|
@@ -401,9 +400,10 @@ export interface ICoreApp<
|
|
|
401
400
|
|
|
402
401
|
/**
|
|
403
402
|
* Switch organization
|
|
404
|
-
* @param
|
|
403
|
+
* @param id Organization id
|
|
404
|
+
* @param serviceId Service id
|
|
405
405
|
*/
|
|
406
|
-
switchOrg(
|
|
406
|
+
switchOrg(id: number, serviceId?: number): Promise<boolean | undefined>;
|
|
407
407
|
|
|
408
408
|
/**
|
|
409
409
|
* Go to the login page
|
|
@@ -589,12 +589,17 @@ export abstract class CoreApp<
|
|
|
589
589
|
/**
|
|
590
590
|
* Device id field name
|
|
591
591
|
*/
|
|
592
|
-
|
|
592
|
+
private readonly deviceIdField: string = 'SmartERPDeviceId';
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Device passphrase field name
|
|
596
|
+
*/
|
|
597
|
+
private readonly devicePassphraseField: string = 'SmartERPDevicePassphrase';
|
|
593
598
|
|
|
594
599
|
/**
|
|
595
600
|
* Device id update time field name
|
|
596
601
|
*/
|
|
597
|
-
|
|
602
|
+
private readonly deviceIdUpdateTimeField: string =
|
|
598
603
|
'SmartERPDeviceIdUpdateTime';
|
|
599
604
|
|
|
600
605
|
/**
|
|
@@ -627,10 +632,7 @@ export abstract class CoreApp<
|
|
|
627
632
|
this.notifier = notifier;
|
|
628
633
|
this.name = name;
|
|
629
634
|
|
|
630
|
-
this.deviceId =
|
|
631
|
-
this.deviceIdField,
|
|
632
|
-
''
|
|
633
|
-
);
|
|
635
|
+
this.deviceId = this.setupDevice();
|
|
634
636
|
|
|
635
637
|
this.setApi(api);
|
|
636
638
|
|
|
@@ -676,6 +678,33 @@ export abstract class CoreApp<
|
|
|
676
678
|
};
|
|
677
679
|
}
|
|
678
680
|
|
|
681
|
+
/**
|
|
682
|
+
* Setup device
|
|
683
|
+
* @returns Device id
|
|
684
|
+
*/
|
|
685
|
+
protected setupDevice() {
|
|
686
|
+
const deviceId = StorageUtils.getLocalData<string>(this.deviceIdField);
|
|
687
|
+
|
|
688
|
+
if (deviceId != null && deviceId !== '') {
|
|
689
|
+
const passphraseEncrypted = StorageUtils.getLocalData<string>(
|
|
690
|
+
this.devicePassphraseField
|
|
691
|
+
);
|
|
692
|
+
if (passphraseEncrypted != null && passphraseEncrypted !== '') {
|
|
693
|
+
const timestamp = this.getDeviceUpdateTime();
|
|
694
|
+
if (timestamp > 0) {
|
|
695
|
+
const passphraseDecrypted = this.decrypt(
|
|
696
|
+
passphraseEncrypted,
|
|
697
|
+
timestamp.toString()
|
|
698
|
+
);
|
|
699
|
+
if (passphraseDecrypted != null)
|
|
700
|
+
this.passphrase = passphraseDecrypted;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
return deviceId ?? '';
|
|
706
|
+
}
|
|
707
|
+
|
|
679
708
|
/**
|
|
680
709
|
* Api init call
|
|
681
710
|
* @param data Data
|
|
@@ -781,6 +810,7 @@ export abstract class CoreApp<
|
|
|
781
810
|
// Update device id and cache it
|
|
782
811
|
this.deviceId = data.deviceId;
|
|
783
812
|
StorageUtils.setLocalData(this.deviceIdField, this.deviceId);
|
|
813
|
+
StorageUtils.setLocalData(this.devicePassphraseField, data.passphrase);
|
|
784
814
|
StorageUtils.setLocalData(this.deviceIdUpdateTimeField, timestamp);
|
|
785
815
|
|
|
786
816
|
// Current passphrase
|
|
@@ -945,6 +975,7 @@ export abstract class CoreApp<
|
|
|
945
975
|
StorageUtils.setLocalData(this.serversideDeviceIdField, undefined);
|
|
946
976
|
|
|
947
977
|
StorageUtils.setLocalData(this.deviceIdField, undefined);
|
|
978
|
+
StorageUtils.setLocalData(this.devicePassphraseField, undefined);
|
|
948
979
|
StorageUtils.setLocalData(this.deviceIdUpdateTimeField, undefined);
|
|
949
980
|
|
|
950
981
|
StorageUtils.setLocalData(this.headerTokenField, undefined);
|
|
@@ -1404,14 +1435,18 @@ export abstract class CoreApp<
|
|
|
1404
1435
|
* Signout
|
|
1405
1436
|
* @param apiUrl Signout API URL
|
|
1406
1437
|
*/
|
|
1407
|
-
async signout(
|
|
1408
|
-
await this.api.put<boolean>(
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1438
|
+
async signout() {
|
|
1439
|
+
await this.api.put<boolean>(
|
|
1440
|
+
'User/Signout',
|
|
1441
|
+
{ deviceId: this.deviceId },
|
|
1442
|
+
{
|
|
1443
|
+
onError: (error) => {
|
|
1444
|
+
console.log(error);
|
|
1445
|
+
// Prevent further processing
|
|
1446
|
+
return false;
|
|
1447
|
+
}
|
|
1413
1448
|
}
|
|
1414
|
-
|
|
1449
|
+
);
|
|
1415
1450
|
|
|
1416
1451
|
// Clear
|
|
1417
1452
|
this.userLogout();
|
|
@@ -1440,10 +1475,15 @@ export abstract class CoreApp<
|
|
|
1440
1475
|
/**
|
|
1441
1476
|
* Switch organization
|
|
1442
1477
|
* @param id Organization id
|
|
1478
|
+
* @param serviceId Service id
|
|
1443
1479
|
*/
|
|
1444
|
-
async switchOrg(id: number) {
|
|
1445
|
-
const api = `Organization/Switch
|
|
1446
|
-
const result = await this.api.put<boolean>(api
|
|
1480
|
+
async switchOrg(id: number, serviceId?: number) {
|
|
1481
|
+
const api = `Organization/Switch`;
|
|
1482
|
+
const result = await this.api.put<boolean>(api, {
|
|
1483
|
+
id,
|
|
1484
|
+
serviceId,
|
|
1485
|
+
deviceId: this.deviceId
|
|
1486
|
+
});
|
|
1447
1487
|
if (result) return await this.refreshToken();
|
|
1448
1488
|
return result;
|
|
1449
1489
|
}
|
|
@@ -1506,7 +1546,7 @@ export abstract class CoreApp<
|
|
|
1506
1546
|
if (keep) {
|
|
1507
1547
|
this.authorize(user.token, refreshToken);
|
|
1508
1548
|
} else {
|
|
1509
|
-
this.cachedRefreshToken = refreshToken;
|
|
1549
|
+
this.cachedRefreshToken = this.encrypt(refreshToken);
|
|
1510
1550
|
this.authorize(user.token, undefined);
|
|
1511
1551
|
}
|
|
1512
1552
|
}
|