@etsoo/materialui 1.4.5 → 1.4.6
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/CommonApp.d.ts +2 -7
- package/lib/app/CommonApp.js +13 -70
- package/lib/app/ReactApp.d.ts +1 -2
- package/lib/app/ReactApp.js +2 -3
- package/lib/app/ServiceApp.d.ts +5 -7
- package/lib/app/ServiceApp.js +12 -9
- package/package.json +8 -8
- package/src/app/CommonApp.ts +16 -99
- package/src/app/ReactApp.ts +2 -8
- package/src/app/ServiceApp.ts +14 -14
package/lib/app/CommonApp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAppSettings, IUser
|
|
1
|
+
import { AppLoginParams, IAppSettings, IUser } from "@etsoo/appscript";
|
|
2
2
|
import { IPageData } from "@etsoo/react";
|
|
3
3
|
import { ReactApp } from "./ReactApp";
|
|
4
4
|
/**
|
|
@@ -15,15 +15,10 @@ export declare abstract class CommonApp<U extends IUser = IUser, P extends IPage
|
|
|
15
15
|
* @returns Fields
|
|
16
16
|
*/
|
|
17
17
|
protected initCallEncryptedUpdateFields(): string[];
|
|
18
|
-
/**
|
|
19
|
-
* Refresh token
|
|
20
|
-
* @param props Props
|
|
21
|
-
*/
|
|
22
|
-
refreshToken(props?: RefreshTokenProps): Promise<boolean>;
|
|
23
18
|
/**
|
|
24
19
|
* Try login
|
|
25
20
|
* @param showLoading Show loading bar or not
|
|
26
21
|
* @returns Result
|
|
27
22
|
*/
|
|
28
|
-
tryLogin(
|
|
23
|
+
tryLogin(params?: AppLoginParams): Promise<void>;
|
|
29
24
|
}
|
package/lib/app/CommonApp.js
CHANGED
|
@@ -20,82 +20,25 @@ export class CommonApp extends ReactApp {
|
|
|
20
20
|
fields.push(CoreConstants.FieldUserIdSaved);
|
|
21
21
|
return fields;
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Refresh token
|
|
25
|
-
* @param props Props
|
|
26
|
-
*/
|
|
27
|
-
async refreshToken(props) {
|
|
28
|
-
// Destruct
|
|
29
|
-
const { callback, showLoading = false } = props ?? {};
|
|
30
|
-
// Token
|
|
31
|
-
const token = this.getCacheToken();
|
|
32
|
-
if (token == null || token === "") {
|
|
33
|
-
if (callback)
|
|
34
|
-
callback(false);
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
// Reqest data
|
|
38
|
-
const rq = {
|
|
39
|
-
deviceId: this.deviceId
|
|
40
|
-
};
|
|
41
|
-
// Payload
|
|
42
|
-
const payload = {
|
|
43
|
-
// No loading bar needed to avoid screen flicks
|
|
44
|
-
showLoading,
|
|
45
|
-
config: { headers: { [CoreConstants.TokenHeaderRefresh]: token } },
|
|
46
|
-
onError: (error) => {
|
|
47
|
-
if (callback)
|
|
48
|
-
callback(error);
|
|
49
|
-
// Prevent further processing
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
// Success callback
|
|
54
|
-
const success = (result, failCallback) => {
|
|
55
|
-
// Token
|
|
56
|
-
const refreshToken = this.getResponseToken(payload.response);
|
|
57
|
-
if (refreshToken == null || result.data == null) {
|
|
58
|
-
if (failCallback)
|
|
59
|
-
failCallback(this.get("noData"));
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
// Keep
|
|
63
|
-
const keep = this.storage.getData(CoreConstants.FieldLoginKeep, false);
|
|
64
|
-
// User login
|
|
65
|
-
this.userLogin(result.data, refreshToken, keep);
|
|
66
|
-
// Callback
|
|
67
|
-
if (failCallback)
|
|
68
|
-
failCallback(true);
|
|
69
|
-
return true;
|
|
70
|
-
};
|
|
71
|
-
// Call API
|
|
72
|
-
const result = await this.api.put("Auth/RefreshToken", rq, payload);
|
|
73
|
-
if (result == null)
|
|
74
|
-
return false;
|
|
75
|
-
if (!result.ok) {
|
|
76
|
-
// Remove the wrong token
|
|
77
|
-
this.clearCacheToken();
|
|
78
|
-
// Callback
|
|
79
|
-
if (callback)
|
|
80
|
-
callback(result);
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
return success(result, callback);
|
|
84
|
-
}
|
|
85
23
|
/**
|
|
86
24
|
* Try login
|
|
87
25
|
* @param showLoading Show loading bar or not
|
|
88
26
|
* @returns Result
|
|
89
27
|
*/
|
|
90
|
-
async tryLogin(
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
28
|
+
async tryLogin(params) {
|
|
29
|
+
// Check status
|
|
30
|
+
if (this.isTryingLogin)
|
|
31
|
+
return;
|
|
32
|
+
this.isTryingLogin = true;
|
|
95
33
|
// Refresh token
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
34
|
+
await this.refreshToken({
|
|
35
|
+
showLoading: params?.showLoading
|
|
36
|
+
}, (result) => {
|
|
37
|
+
if (result) {
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.toLoginPage(params);
|
|
41
|
+
}
|
|
99
42
|
});
|
|
100
43
|
}
|
|
101
44
|
}
|
package/lib/app/ReactApp.d.ts
CHANGED
|
@@ -211,10 +211,9 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
|
|
|
211
211
|
* User login extended
|
|
212
212
|
* @param user New user
|
|
213
213
|
* @param refreshToken Refresh token
|
|
214
|
-
* @param keep Keep in local storage or not
|
|
215
214
|
* @param dispatch User state dispatch
|
|
216
215
|
*/
|
|
217
|
-
userLogin(user: D, refreshToken: string,
|
|
216
|
+
userLogin(user: D, refreshToken: string, dispatch?: boolean): void;
|
|
218
217
|
/**
|
|
219
218
|
* User logout
|
|
220
219
|
* @param clearToken Clear refresh token or not
|
package/lib/app/ReactApp.js
CHANGED
|
@@ -257,12 +257,11 @@ export class ReactApp extends CoreApp {
|
|
|
257
257
|
* User login extended
|
|
258
258
|
* @param user New user
|
|
259
259
|
* @param refreshToken Refresh token
|
|
260
|
-
* @param keep Keep in local storage or not
|
|
261
260
|
* @param dispatch User state dispatch
|
|
262
261
|
*/
|
|
263
|
-
userLogin(user, refreshToken,
|
|
262
|
+
userLogin(user, refreshToken, dispatch) {
|
|
264
263
|
// Super call, set token
|
|
265
|
-
super.userLogin(user, refreshToken
|
|
264
|
+
super.userLogin(user, refreshToken);
|
|
266
265
|
// Dispatch action
|
|
267
266
|
if (this.userStateDispatch != null && dispatch !== false)
|
|
268
267
|
this.userStateDispatch({
|
package/lib/app/ServiceApp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiRefreshTokenDto, ExternalEndpoint, IApi } from "@etsoo/appscript";
|
|
1
|
+
import { ApiRefreshTokenDto, AppLoginParams, ExternalEndpoint, IApi } from "@etsoo/appscript";
|
|
2
2
|
import { IServiceApp } from "./IServiceApp";
|
|
3
3
|
import { IServiceAppSettings } from "./IServiceAppSettings";
|
|
4
4
|
import { IServicePageData } from "./IServicePage";
|
|
@@ -36,18 +36,16 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
36
36
|
loadCore(): void;
|
|
37
37
|
/**
|
|
38
38
|
* Go to the login page
|
|
39
|
-
* @
|
|
40
|
-
* @param removeUrl Remove current URL for reuse
|
|
39
|
+
* @params Login parameters
|
|
41
40
|
*/
|
|
42
|
-
toLoginPage(
|
|
41
|
+
toLoginPage(params?: AppLoginParams): void;
|
|
43
42
|
/**
|
|
44
43
|
* User login extended
|
|
45
44
|
* @param user New user
|
|
46
45
|
* @param refreshToken Refresh token
|
|
47
|
-
* @param keep Keep in local storage or not
|
|
48
46
|
* @param dispatch User state dispatch
|
|
49
47
|
*/
|
|
50
|
-
userLogin(user: U, refreshToken: string,
|
|
48
|
+
userLogin(user: U, refreshToken: string, dispatch?: boolean): void;
|
|
51
49
|
/**
|
|
52
50
|
*
|
|
53
51
|
* @param user Current user
|
|
@@ -55,5 +53,5 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
55
53
|
* @param keep Keep in local storage or not
|
|
56
54
|
* @param dispatch User state dispatch
|
|
57
55
|
*/
|
|
58
|
-
userLoginEx(user: U & ServiceUserToken, core?: ApiRefreshTokenDto,
|
|
56
|
+
userLoginEx(user: U & ServiceUserToken, core?: ApiRefreshTokenDto, dispatch?: boolean): void;
|
|
59
57
|
}
|
package/lib/app/ServiceApp.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AuthApi, BridgeUtils } from "@etsoo/appscript";
|
|
2
2
|
import { ReactApp } from "./ReactApp";
|
|
3
3
|
const coreName = "core";
|
|
4
|
+
const coreTokenKey = "core-refresh-token";
|
|
4
5
|
/**
|
|
5
6
|
* Core Service App
|
|
6
7
|
* Service login to core system, get the refesh token and access token
|
|
@@ -37,10 +38,11 @@ export class ServiceApp extends ReactApp {
|
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* Go to the login page
|
|
40
|
-
* @
|
|
41
|
-
* @param removeUrl Remove current URL for reuse
|
|
41
|
+
* @params Login parameters
|
|
42
42
|
*/
|
|
43
|
-
toLoginPage(
|
|
43
|
+
toLoginPage(params) {
|
|
44
|
+
// Destruct
|
|
45
|
+
const { removeUrl, showLoading, ...rest } = params ?? {};
|
|
44
46
|
// Cache current URL
|
|
45
47
|
this.cachedUrl = removeUrl ? undefined : globalThis.location.href;
|
|
46
48
|
// Get the redirect URL
|
|
@@ -53,7 +55,7 @@ export class ServiceApp extends ReactApp {
|
|
|
53
55
|
if (!url)
|
|
54
56
|
return;
|
|
55
57
|
// Add try login flag
|
|
56
|
-
url = url.
|
|
58
|
+
url = url.addUrlParams(rest);
|
|
57
59
|
// Is it embeded?
|
|
58
60
|
if (this.embedded) {
|
|
59
61
|
globalThis.parent.postMessage(["login", url], this.coreOrigin);
|
|
@@ -74,10 +76,9 @@ export class ServiceApp extends ReactApp {
|
|
|
74
76
|
* User login extended
|
|
75
77
|
* @param user New user
|
|
76
78
|
* @param refreshToken Refresh token
|
|
77
|
-
* @param keep Keep in local storage or not
|
|
78
79
|
* @param dispatch User state dispatch
|
|
79
80
|
*/
|
|
80
|
-
userLogin(user, refreshToken,
|
|
81
|
+
userLogin(user, refreshToken, dispatch) {
|
|
81
82
|
if (user.clientDeviceId && user.passphrase) {
|
|
82
83
|
// Save the passphrase
|
|
83
84
|
// Interpolated string expressions are different between TypeScript and C# for the null value
|
|
@@ -88,7 +89,7 @@ export class ServiceApp extends ReactApp {
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
// Super call, set token
|
|
91
|
-
super.userLogin(user, refreshToken,
|
|
92
|
+
super.userLogin(user, refreshToken, dispatch);
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
94
95
|
*
|
|
@@ -97,10 +98,10 @@ export class ServiceApp extends ReactApp {
|
|
|
97
98
|
* @param keep Keep in local storage or not
|
|
98
99
|
* @param dispatch User state dispatch
|
|
99
100
|
*/
|
|
100
|
-
userLoginEx(user, core,
|
|
101
|
+
userLoginEx(user, core, dispatch) {
|
|
101
102
|
// User login
|
|
102
103
|
const { refreshToken } = user;
|
|
103
|
-
this.userLogin(user, refreshToken,
|
|
104
|
+
this.userLogin(user, refreshToken, dispatch);
|
|
104
105
|
// Core system login
|
|
105
106
|
core ?? (core = {
|
|
106
107
|
refreshToken,
|
|
@@ -108,6 +109,8 @@ export class ServiceApp extends ReactApp {
|
|
|
108
109
|
tokenType: user.tokenScheme ?? "Bearer",
|
|
109
110
|
expiresIn: user.seconds
|
|
110
111
|
});
|
|
112
|
+
// Cache the core system refresh token
|
|
113
|
+
this.storage.setData(coreTokenKey, core.refreshToken);
|
|
111
114
|
this.exchangeTokenAll(core, coreName);
|
|
112
115
|
}
|
|
113
116
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,14 +50,14 @@
|
|
|
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.
|
|
53
|
+
"@etsoo/appscript": "^1.5.47",
|
|
54
54
|
"@etsoo/notificationbase": "^1.1.49",
|
|
55
|
-
"@etsoo/react": "^1.7.
|
|
55
|
+
"@etsoo/react": "^1.7.80",
|
|
56
56
|
"@etsoo/shared": "^1.2.48",
|
|
57
|
-
"@mui/icons-material": "^6.1.
|
|
58
|
-
"@mui/material": "^6.1.
|
|
57
|
+
"@mui/icons-material": "^6.1.4",
|
|
58
|
+
"@mui/material": "^6.1.4",
|
|
59
59
|
"@mui/x-data-grid": "^7.20.0",
|
|
60
|
-
"chart.js": "^4.4.
|
|
60
|
+
"chart.js": "^4.4.5",
|
|
61
61
|
"chartjs-plugin-datalabels": "^2.2.0",
|
|
62
62
|
"eventemitter3": "^5.0.1",
|
|
63
63
|
"pica": "^9.0.1",
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"@types/react-dom": "^18.3.1",
|
|
88
88
|
"@types/react-input-mask": "^3.0.5",
|
|
89
89
|
"@types/react-window": "^1.8.8",
|
|
90
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
91
|
-
"@typescript-eslint/parser": "^8.
|
|
90
|
+
"@typescript-eslint/eslint-plugin": "^8.9.0",
|
|
91
|
+
"@typescript-eslint/parser": "^8.9.0",
|
|
92
92
|
"jest": "^29.7.0",
|
|
93
93
|
"jest-environment-jsdom": "^29.7.0",
|
|
94
94
|
"typescript": "^5.6.3"
|
package/src/app/CommonApp.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IApiPayload,
|
|
3
|
-
IAppSettings,
|
|
4
|
-
IUser,
|
|
5
|
-
RefreshTokenProps,
|
|
6
|
-
RefreshTokenResult,
|
|
7
|
-
RefreshTokenRQ
|
|
8
|
-
} from "@etsoo/appscript";
|
|
1
|
+
import { AppLoginParams, IAppSettings, IUser } from "@etsoo/appscript";
|
|
9
2
|
import { CoreConstants, IPageData } from "@etsoo/react";
|
|
10
3
|
import { ReactApp } from "./ReactApp";
|
|
11
|
-
import { IActionResult } from "@etsoo/shared";
|
|
12
4
|
|
|
13
5
|
/**
|
|
14
6
|
* Common independent application
|
|
@@ -36,102 +28,27 @@ export abstract class CommonApp<
|
|
|
36
28
|
return fields;
|
|
37
29
|
}
|
|
38
30
|
|
|
39
|
-
/**
|
|
40
|
-
* Refresh token
|
|
41
|
-
* @param props Props
|
|
42
|
-
*/
|
|
43
|
-
override async refreshToken(props?: RefreshTokenProps) {
|
|
44
|
-
// Destruct
|
|
45
|
-
const { callback, showLoading = false } = props ?? {};
|
|
46
|
-
|
|
47
|
-
// Token
|
|
48
|
-
const token = this.getCacheToken();
|
|
49
|
-
if (token == null || token === "") {
|
|
50
|
-
if (callback) callback(false);
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Reqest data
|
|
55
|
-
const rq: RefreshTokenRQ = {
|
|
56
|
-
deviceId: this.deviceId
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// Login result type
|
|
60
|
-
type LoginResult = IActionResult<U>;
|
|
61
|
-
|
|
62
|
-
// Payload
|
|
63
|
-
const payload: IApiPayload<LoginResult, any> = {
|
|
64
|
-
// No loading bar needed to avoid screen flicks
|
|
65
|
-
showLoading,
|
|
66
|
-
config: { headers: { [CoreConstants.TokenHeaderRefresh]: token } },
|
|
67
|
-
onError: (error) => {
|
|
68
|
-
if (callback) callback(error);
|
|
69
|
-
|
|
70
|
-
// Prevent further processing
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// Success callback
|
|
76
|
-
const success = (
|
|
77
|
-
result: LoginResult,
|
|
78
|
-
failCallback?: (result: RefreshTokenResult) => void
|
|
79
|
-
) => {
|
|
80
|
-
// Token
|
|
81
|
-
const refreshToken = this.getResponseToken(payload.response);
|
|
82
|
-
if (refreshToken == null || result.data == null) {
|
|
83
|
-
if (failCallback) failCallback(this.get("noData")!);
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Keep
|
|
88
|
-
const keep = this.storage.getData(CoreConstants.FieldLoginKeep, false);
|
|
89
|
-
|
|
90
|
-
// User login
|
|
91
|
-
this.userLogin(result.data, refreshToken, keep);
|
|
92
|
-
|
|
93
|
-
// Callback
|
|
94
|
-
if (failCallback) failCallback(true);
|
|
95
|
-
|
|
96
|
-
return true;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// Call API
|
|
100
|
-
const result = await this.api.put<LoginResult>(
|
|
101
|
-
"Auth/RefreshToken",
|
|
102
|
-
rq,
|
|
103
|
-
payload
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
if (result == null) return false;
|
|
107
|
-
|
|
108
|
-
if (!result.ok) {
|
|
109
|
-
// Remove the wrong token
|
|
110
|
-
this.clearCacheToken();
|
|
111
|
-
|
|
112
|
-
// Callback
|
|
113
|
-
if (callback) callback(result);
|
|
114
|
-
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return success(result, callback);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
31
|
/**
|
|
122
32
|
* Try login
|
|
123
33
|
* @param showLoading Show loading bar or not
|
|
124
34
|
* @returns Result
|
|
125
35
|
*/
|
|
126
|
-
override async tryLogin(
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
|
|
36
|
+
override async tryLogin(params?: AppLoginParams) {
|
|
37
|
+
// Check status
|
|
38
|
+
if (this.isTryingLogin) return;
|
|
39
|
+
this.isTryingLogin = true;
|
|
130
40
|
|
|
131
41
|
// Refresh token
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
42
|
+
await this.refreshToken(
|
|
43
|
+
{
|
|
44
|
+
showLoading: params?.showLoading
|
|
45
|
+
},
|
|
46
|
+
(result) => {
|
|
47
|
+
if (result) {
|
|
48
|
+
} else {
|
|
49
|
+
this.toLoginPage(params);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
);
|
|
136
53
|
}
|
|
137
54
|
}
|
package/src/app/ReactApp.ts
CHANGED
|
@@ -494,17 +494,11 @@ export class ReactApp<
|
|
|
494
494
|
* User login extended
|
|
495
495
|
* @param user New user
|
|
496
496
|
* @param refreshToken Refresh token
|
|
497
|
-
* @param keep Keep in local storage or not
|
|
498
497
|
* @param dispatch User state dispatch
|
|
499
498
|
*/
|
|
500
|
-
override userLogin(
|
|
501
|
-
user: D,
|
|
502
|
-
refreshToken: string,
|
|
503
|
-
keep?: boolean,
|
|
504
|
-
dispatch?: boolean
|
|
505
|
-
): void {
|
|
499
|
+
override userLogin(user: D, refreshToken: string, dispatch?: boolean): void {
|
|
506
500
|
// Super call, set token
|
|
507
|
-
super.userLogin(user, refreshToken
|
|
501
|
+
super.userLogin(user, refreshToken);
|
|
508
502
|
|
|
509
503
|
// Dispatch action
|
|
510
504
|
if (this.userStateDispatch != null && dispatch !== false)
|
package/src/app/ServiceApp.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ApiRefreshTokenDto,
|
|
3
|
+
AppLoginParams,
|
|
3
4
|
AuthApi,
|
|
4
5
|
BridgeUtils,
|
|
5
6
|
ExternalEndpoint,
|
|
@@ -12,6 +13,7 @@ import { IServiceUser, ServiceUserToken } from "./IServiceUser";
|
|
|
12
13
|
import { ReactApp } from "./ReactApp";
|
|
13
14
|
|
|
14
15
|
const coreName = "core";
|
|
16
|
+
const coreTokenKey = "core-refresh-token";
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Core Service App
|
|
@@ -73,10 +75,12 @@ export class ServiceApp<
|
|
|
73
75
|
|
|
74
76
|
/**
|
|
75
77
|
* Go to the login page
|
|
76
|
-
* @
|
|
77
|
-
* @param removeUrl Remove current URL for reuse
|
|
78
|
+
* @params Login parameters
|
|
78
79
|
*/
|
|
79
|
-
override toLoginPage(
|
|
80
|
+
override toLoginPage(params?: AppLoginParams) {
|
|
81
|
+
// Destruct
|
|
82
|
+
const { removeUrl, showLoading, ...rest } = params ?? {};
|
|
83
|
+
|
|
80
84
|
// Cache current URL
|
|
81
85
|
this.cachedUrl = removeUrl ? undefined : globalThis.location.href;
|
|
82
86
|
|
|
@@ -90,7 +94,7 @@ export class ServiceApp<
|
|
|
90
94
|
if (!url) return;
|
|
91
95
|
|
|
92
96
|
// Add try login flag
|
|
93
|
-
url = url.
|
|
97
|
+
url = url.addUrlParams(rest);
|
|
94
98
|
|
|
95
99
|
// Is it embeded?
|
|
96
100
|
if (this.embedded) {
|
|
@@ -112,15 +116,9 @@ export class ServiceApp<
|
|
|
112
116
|
* User login extended
|
|
113
117
|
* @param user New user
|
|
114
118
|
* @param refreshToken Refresh token
|
|
115
|
-
* @param keep Keep in local storage or not
|
|
116
119
|
* @param dispatch User state dispatch
|
|
117
120
|
*/
|
|
118
|
-
override userLogin(
|
|
119
|
-
user: U,
|
|
120
|
-
refreshToken: string,
|
|
121
|
-
keep?: boolean,
|
|
122
|
-
dispatch?: boolean
|
|
123
|
-
): void {
|
|
121
|
+
override userLogin(user: U, refreshToken: string, dispatch?: boolean): void {
|
|
124
122
|
if (user.clientDeviceId && user.passphrase) {
|
|
125
123
|
// Save the passphrase
|
|
126
124
|
// Interpolated string expressions are different between TypeScript and C# for the null value
|
|
@@ -135,7 +133,7 @@ export class ServiceApp<
|
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
// Super call, set token
|
|
138
|
-
super.userLogin(user, refreshToken,
|
|
136
|
+
super.userLogin(user, refreshToken, dispatch);
|
|
139
137
|
}
|
|
140
138
|
|
|
141
139
|
/**
|
|
@@ -148,12 +146,11 @@ export class ServiceApp<
|
|
|
148
146
|
userLoginEx(
|
|
149
147
|
user: U & ServiceUserToken,
|
|
150
148
|
core?: ApiRefreshTokenDto,
|
|
151
|
-
keep?: boolean,
|
|
152
149
|
dispatch?: boolean
|
|
153
150
|
) {
|
|
154
151
|
// User login
|
|
155
152
|
const { refreshToken } = user;
|
|
156
|
-
this.userLogin(user, refreshToken,
|
|
153
|
+
this.userLogin(user, refreshToken, dispatch);
|
|
157
154
|
|
|
158
155
|
// Core system login
|
|
159
156
|
core ??= {
|
|
@@ -163,6 +160,9 @@ export class ServiceApp<
|
|
|
163
160
|
expiresIn: user.seconds
|
|
164
161
|
};
|
|
165
162
|
|
|
163
|
+
// Cache the core system refresh token
|
|
164
|
+
this.storage.setData(coreTokenKey, core.refreshToken);
|
|
165
|
+
|
|
166
166
|
this.exchangeTokenAll(core, coreName);
|
|
167
167
|
}
|
|
168
168
|
}
|