@abpjs/account 2.2.0 → 2.7.0
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/dist/components/AuthWrapper/AuthWrapper.d.ts +19 -1
- package/dist/components/LoginForm/LoginForm.d.ts +4 -0
- package/dist/components/ManageProfile/ManageProfile.d.ts +5 -0
- package/dist/components/RegisterForm/RegisterForm.d.ts +4 -0
- package/dist/components/TenantBox/TenantBox.d.ts +5 -0
- package/dist/enums/components.d.ts +52 -0
- package/dist/enums/index.d.ts +7 -0
- package/dist/enums/route-names.d.ts +40 -0
- package/dist/index.d.ts +18 -2
- package/dist/index.js +102 -24
- package/dist/index.mjs +100 -24
- package/dist/models/index.d.ts +7 -0
- package/dist/services/account.service.d.ts +8 -0
- package/package.json +4 -4
|
@@ -24,6 +24,18 @@ export interface AuthWrapperProps {
|
|
|
24
24
|
* @default true (from ABP settings or if not configured)
|
|
25
25
|
*/
|
|
26
26
|
enableLocalLogin?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether multi-tenancy is enabled.
|
|
29
|
+
* When true, the tenant box will be displayed (if rendered).
|
|
30
|
+
* This corresponds to Angular's isMultiTenancyEnabled$ observable.
|
|
31
|
+
*
|
|
32
|
+
* In ABP, this is read from ConfigState.getDeep('multiTenancy.isEnabled').
|
|
33
|
+
* This prop allows overriding the default behavior.
|
|
34
|
+
*
|
|
35
|
+
* @since 2.4.0
|
|
36
|
+
* @default true (multi-tenancy enabled by default)
|
|
37
|
+
*/
|
|
38
|
+
isMultiTenancyEnabled?: boolean;
|
|
27
39
|
}
|
|
28
40
|
/**
|
|
29
41
|
* AuthWrapper - Authentication wrapper component
|
|
@@ -37,14 +49,20 @@ export interface AuthWrapperProps {
|
|
|
37
49
|
*
|
|
38
50
|
* @since 1.1.0
|
|
39
51
|
* @since 2.0.0 - Added enableLocalLogin prop to control local login visibility
|
|
52
|
+
* @since 2.4.0 - Added isMultiTenancyEnabled prop (equivalent to Angular's isMultiTenancyEnabled$)
|
|
53
|
+
* @since 2.7.0 - Added tenantBoxKey static property for component replacement system
|
|
40
54
|
*
|
|
41
55
|
* @example
|
|
42
56
|
* ```tsx
|
|
43
57
|
* <AuthWrapper
|
|
44
58
|
* mainContent={<LoginForm />}
|
|
45
59
|
* cancelContent={<Link to="/register">Create account</Link>}
|
|
60
|
+
* isMultiTenancyEnabled={true}
|
|
46
61
|
* />
|
|
47
62
|
* ```
|
|
48
63
|
*/
|
|
49
|
-
export declare function AuthWrapper({ children, mainContent, cancelContent, enableLocalLogin, }: AuthWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
64
|
+
export declare function AuthWrapper({ children, mainContent, cancelContent, enableLocalLogin, isMultiTenancyEnabled, }: AuthWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
export declare namespace AuthWrapper {
|
|
66
|
+
var tenantBoxKey: "Account.TenantBoxComponent";
|
|
67
|
+
}
|
|
50
68
|
export default AuthWrapper;
|
|
@@ -33,6 +33,7 @@ export interface LoginFormProps {
|
|
|
33
33
|
* It handles user authentication using OAuth password flow.
|
|
34
34
|
*
|
|
35
35
|
* @since 2.0.0 - Added isSelfRegistrationEnabled check from ABP settings
|
|
36
|
+
* @since 2.7.0 - Added authWrapperKey static property for component replacement system
|
|
36
37
|
*
|
|
37
38
|
* @example
|
|
38
39
|
* ```tsx
|
|
@@ -47,4 +48,7 @@ export interface LoginFormProps {
|
|
|
47
48
|
* ```
|
|
48
49
|
*/
|
|
49
50
|
export declare function LoginForm({ showTenantBox, showRegisterLink, registerUrl, onLoginSuccess, onLoginError, }: LoginFormProps): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
export declare namespace LoginForm {
|
|
52
|
+
var authWrapperKey: "Account.AuthWrapperComponent";
|
|
53
|
+
}
|
|
50
54
|
export default LoginForm;
|
|
@@ -33,6 +33,7 @@ export interface ManageProfileProps {
|
|
|
33
33
|
* including personal information and password change.
|
|
34
34
|
*
|
|
35
35
|
* @since 1.1.0
|
|
36
|
+
* @since 2.7.0 - Added changePasswordKey and personalSettingsKey static properties for component replacement system
|
|
36
37
|
*
|
|
37
38
|
* @example
|
|
38
39
|
* ```tsx
|
|
@@ -43,4 +44,8 @@ export interface ManageProfileProps {
|
|
|
43
44
|
* ```
|
|
44
45
|
*/
|
|
45
46
|
export declare function ManageProfile({ defaultTabIndex, onTabChange, customTabs, }: ManageProfileProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
export declare namespace ManageProfile {
|
|
48
|
+
var changePasswordKey: "Account.ChangePasswordComponent";
|
|
49
|
+
var personalSettingsKey: "Account.PersonalSettingsComponent";
|
|
50
|
+
}
|
|
46
51
|
export default ManageProfile;
|
|
@@ -36,6 +36,7 @@ export interface RegisterFormProps {
|
|
|
36
36
|
*
|
|
37
37
|
* @since 0.9.0 - Now uses AccountService for registration
|
|
38
38
|
* @since 2.0.0 - Added isSelfRegistrationEnabled check from ABP settings
|
|
39
|
+
* @since 2.7.0 - Added authWrapperKey static property for component replacement system
|
|
39
40
|
*
|
|
40
41
|
* @example
|
|
41
42
|
* ```tsx
|
|
@@ -50,4 +51,7 @@ export interface RegisterFormProps {
|
|
|
50
51
|
* ```
|
|
51
52
|
*/
|
|
52
53
|
export declare function RegisterForm({ showTenantBox, showLoginLink, loginUrl, onRegisterSuccess, onRegisterError, }: RegisterFormProps): import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
export declare namespace RegisterForm {
|
|
55
|
+
var authWrapperKey: "Account.AuthWrapperComponent";
|
|
56
|
+
}
|
|
53
57
|
export default RegisterForm;
|
|
@@ -18,6 +18,11 @@ export interface TenantBoxProps {
|
|
|
18
18
|
* and properly updates the session state.
|
|
19
19
|
*
|
|
20
20
|
* @since 0.9.0 - Now uses AccountService for tenant lookup
|
|
21
|
+
* @since 2.7.0 - Renamed internal properties (name, modalBusy) to match Angular v2.7.0
|
|
22
|
+
* Uses TenantIdResponse.name from API when available
|
|
21
23
|
*/
|
|
22
24
|
export declare function TenantBox({ containerStyle }: TenantBoxProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare namespace TenantBox {
|
|
26
|
+
var componentKey: "Account.TenantBoxComponent";
|
|
27
|
+
}
|
|
23
28
|
export default TenantBox;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Account component keys for component replacement system
|
|
3
|
+
*
|
|
4
|
+
* These keys are used by ABP's component replacement system to allow
|
|
5
|
+
* customization of account module components.
|
|
6
|
+
*
|
|
7
|
+
* Translated from @abp/ng.account v2.7.0 eAccountComponents enum.
|
|
8
|
+
*
|
|
9
|
+
* @since 2.7.0
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { eAccountComponents } from '@abpjs/account';
|
|
14
|
+
*
|
|
15
|
+
* // Use in component replacement
|
|
16
|
+
* const key = eAccountComponents.Login;
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const eAccountComponents: {
|
|
20
|
+
/**
|
|
21
|
+
* Key for the Login component
|
|
22
|
+
*/
|
|
23
|
+
readonly Login: "Account.LoginComponent";
|
|
24
|
+
/**
|
|
25
|
+
* Key for the Register component
|
|
26
|
+
*/
|
|
27
|
+
readonly Register: "Account.RegisterComponent";
|
|
28
|
+
/**
|
|
29
|
+
* Key for the ManageProfile component
|
|
30
|
+
*/
|
|
31
|
+
readonly ManageProfile: "Account.ManageProfileComponent";
|
|
32
|
+
/**
|
|
33
|
+
* Key for the TenantBox component
|
|
34
|
+
*/
|
|
35
|
+
readonly TenantBox: "Account.TenantBoxComponent";
|
|
36
|
+
/**
|
|
37
|
+
* Key for the AuthWrapper component
|
|
38
|
+
*/
|
|
39
|
+
readonly AuthWrapper: "Account.AuthWrapperComponent";
|
|
40
|
+
/**
|
|
41
|
+
* Key for the ChangePassword component
|
|
42
|
+
*/
|
|
43
|
+
readonly ChangePassword: "Account.ChangePasswordComponent";
|
|
44
|
+
/**
|
|
45
|
+
* Key for the PersonalSettings component
|
|
46
|
+
*/
|
|
47
|
+
readonly PersonalSettings: "Account.PersonalSettingsComponent";
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Type for eAccountComponents values
|
|
51
|
+
*/
|
|
52
|
+
export type eAccountComponents = (typeof eAccountComponents)[keyof typeof eAccountComponents];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Account route names for navigation
|
|
3
|
+
*
|
|
4
|
+
* These constants represent localization keys for account route names
|
|
5
|
+
* in the ABP Framework navigation system.
|
|
6
|
+
*
|
|
7
|
+
* Translated from @abp/ng.account v2.7.0 eAccountRouteNames enum.
|
|
8
|
+
*
|
|
9
|
+
* @since 2.7.0
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { eAccountRouteNames } from '@abpjs/account';
|
|
14
|
+
*
|
|
15
|
+
* // Use in route configuration
|
|
16
|
+
* const routeName = eAccountRouteNames.Login;
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const eAccountRouteNames: {
|
|
20
|
+
/**
|
|
21
|
+
* Route name for Account menu
|
|
22
|
+
*/
|
|
23
|
+
readonly Account: "AbpAccount::Menu:Account";
|
|
24
|
+
/**
|
|
25
|
+
* Route name for Login page
|
|
26
|
+
*/
|
|
27
|
+
readonly Login: "AbpAccount::Login";
|
|
28
|
+
/**
|
|
29
|
+
* Route name for Register page
|
|
30
|
+
*/
|
|
31
|
+
readonly Register: "AbpAccount::Register";
|
|
32
|
+
/**
|
|
33
|
+
* Route name for Manage Profile page
|
|
34
|
+
*/
|
|
35
|
+
readonly ManageProfile: "AbpAccount::ManageYourProfile";
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Type for eAccountRouteNames values
|
|
39
|
+
*/
|
|
40
|
+
export type eAccountRouteNames = (typeof eAccountRouteNames)[keyof typeof eAccountRouteNames];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @abpjs/account
|
|
3
3
|
* ABP Framework Account module for React
|
|
4
|
-
* Translated from @abp/ng.account v2.
|
|
4
|
+
* Translated from @abp/ng.account v2.7.0
|
|
5
|
+
*
|
|
6
|
+
* Changes in v2.7.0:
|
|
7
|
+
* - Added eAccountComponents enum for component replacement system
|
|
8
|
+
* - Added eAccountRouteNames enum for route names
|
|
9
|
+
* - TenantIdResponse: Added name property
|
|
10
|
+
* - TenantBoxComponent: Refactored with new naming (name, modalBusy)
|
|
11
|
+
* - Components now have component keys for replacement system
|
|
12
|
+
*
|
|
13
|
+
* Changes in v2.4.0:
|
|
14
|
+
* - AuthWrapperComponent: Added isMultiTenancyEnabled prop (equivalent to Angular's isMultiTenancyEnabled$)
|
|
15
|
+
* - AccountService: Added apiName property for REST API configuration
|
|
16
|
+
* - Dependency updates to @abp/ng.theme.shared v2.4.0 and @abp/ng.account.config v2.4.0
|
|
5
17
|
*
|
|
6
18
|
* Changes in v2.2.0:
|
|
7
19
|
* - Dependency updates to @abp/ng.theme.shared v2.2.0 and @abp/ng.account.config v2.2.0
|
|
8
20
|
* - No functional code changes
|
|
9
21
|
*
|
|
10
|
-
* @version 2.
|
|
22
|
+
* @version 2.7.0
|
|
11
23
|
* @since 2.0.0 - Added Account namespace with component interface types
|
|
12
24
|
* @since 2.0.0 - Added isSelfRegistrationEnabled support in Login/Register components
|
|
13
25
|
* @since 2.0.0 - Added enableLocalLogin support in AuthWrapper component
|
|
14
26
|
* @since 2.0.0 - Removed deprecated ACCOUNT_ROUTES (use AccountProvider instead)
|
|
15
27
|
* @since 2.0.0 - TenantBoxComponent and AccountService now publicly exported
|
|
16
28
|
* @since 2.1.0 - Version bump only (dependency updates to @abp/ng.theme.shared v2.1.0)
|
|
29
|
+
* @since 2.4.0 - AuthWrapper: isMultiTenancyEnabled prop; AccountService: apiName property
|
|
30
|
+
* @since 2.7.0 - Added eAccountComponents and eAccountRouteNames enums
|
|
31
|
+
* @since 2.7.0 - Components have static keys for component replacement system
|
|
17
32
|
*/
|
|
33
|
+
export * from './enums';
|
|
18
34
|
export * from './models';
|
|
19
35
|
export * from './services';
|
|
20
36
|
export * from './providers';
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,8 @@ __export(index_exports, {
|
|
|
33
33
|
RegisterForm: () => RegisterForm,
|
|
34
34
|
RegisterPage: () => RegisterPage,
|
|
35
35
|
TenantBox: () => TenantBox,
|
|
36
|
+
eAccountComponents: () => eAccountComponents,
|
|
37
|
+
eAccountRouteNames: () => eAccountRouteNames,
|
|
36
38
|
useAccountContext: () => useAccountContext,
|
|
37
39
|
useAccountOptions: () => useAccountOptions,
|
|
38
40
|
useAccountService: () => useAccountService,
|
|
@@ -41,10 +43,69 @@ __export(index_exports, {
|
|
|
41
43
|
});
|
|
42
44
|
module.exports = __toCommonJS(index_exports);
|
|
43
45
|
|
|
46
|
+
// src/enums/components.ts
|
|
47
|
+
var eAccountComponents = {
|
|
48
|
+
/**
|
|
49
|
+
* Key for the Login component
|
|
50
|
+
*/
|
|
51
|
+
Login: "Account.LoginComponent",
|
|
52
|
+
/**
|
|
53
|
+
* Key for the Register component
|
|
54
|
+
*/
|
|
55
|
+
Register: "Account.RegisterComponent",
|
|
56
|
+
/**
|
|
57
|
+
* Key for the ManageProfile component
|
|
58
|
+
*/
|
|
59
|
+
ManageProfile: "Account.ManageProfileComponent",
|
|
60
|
+
/**
|
|
61
|
+
* Key for the TenantBox component
|
|
62
|
+
*/
|
|
63
|
+
TenantBox: "Account.TenantBoxComponent",
|
|
64
|
+
/**
|
|
65
|
+
* Key for the AuthWrapper component
|
|
66
|
+
*/
|
|
67
|
+
AuthWrapper: "Account.AuthWrapperComponent",
|
|
68
|
+
/**
|
|
69
|
+
* Key for the ChangePassword component
|
|
70
|
+
*/
|
|
71
|
+
ChangePassword: "Account.ChangePasswordComponent",
|
|
72
|
+
/**
|
|
73
|
+
* Key for the PersonalSettings component
|
|
74
|
+
*/
|
|
75
|
+
PersonalSettings: "Account.PersonalSettingsComponent"
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/enums/route-names.ts
|
|
79
|
+
var eAccountRouteNames = {
|
|
80
|
+
/**
|
|
81
|
+
* Route name for Account menu
|
|
82
|
+
*/
|
|
83
|
+
Account: "AbpAccount::Menu:Account",
|
|
84
|
+
/**
|
|
85
|
+
* Route name for Login page
|
|
86
|
+
*/
|
|
87
|
+
Login: "AbpAccount::Login",
|
|
88
|
+
/**
|
|
89
|
+
* Route name for Register page
|
|
90
|
+
*/
|
|
91
|
+
Register: "AbpAccount::Register",
|
|
92
|
+
/**
|
|
93
|
+
* Route name for Manage Profile page
|
|
94
|
+
*/
|
|
95
|
+
ManageProfile: "AbpAccount::ManageYourProfile"
|
|
96
|
+
};
|
|
97
|
+
|
|
44
98
|
// src/services/account.service.ts
|
|
45
99
|
var AccountService = class {
|
|
46
100
|
constructor(rest) {
|
|
47
101
|
this.rest = rest;
|
|
102
|
+
/**
|
|
103
|
+
* The API name used for REST requests.
|
|
104
|
+
* This corresponds to the key in the environment.apis configuration.
|
|
105
|
+
*
|
|
106
|
+
* @since 2.4.0
|
|
107
|
+
*/
|
|
108
|
+
this.apiName = "default";
|
|
48
109
|
}
|
|
49
110
|
/**
|
|
50
111
|
* Find a tenant by name
|
|
@@ -238,7 +299,8 @@ function AuthWrapper({
|
|
|
238
299
|
children,
|
|
239
300
|
mainContent,
|
|
240
301
|
cancelContent,
|
|
241
|
-
enableLocalLogin
|
|
302
|
+
enableLocalLogin,
|
|
303
|
+
isMultiTenancyEnabled = true
|
|
242
304
|
}) {
|
|
243
305
|
const { t } = (0, import_core4.useLocalization)();
|
|
244
306
|
const localLoginSetting = (0, import_core4.useSetting)(ENABLE_LOCAL_LOGIN_SETTING);
|
|
@@ -251,6 +313,7 @@ function AuthWrapper({
|
|
|
251
313
|
cancelContent && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react4.Box, { textAlign: "center", mt: 4, children: cancelContent })
|
|
252
314
|
] }) }) }) });
|
|
253
315
|
}
|
|
316
|
+
AuthWrapper.tenantBoxKey = eAccountComponents.TenantBox;
|
|
254
317
|
|
|
255
318
|
// src/components/ChangePasswordForm/ChangePasswordForm.tsx
|
|
256
319
|
var import_react5 = require("react");
|
|
@@ -408,47 +471,55 @@ function TenantBox({ containerStyle }) {
|
|
|
408
471
|
const accountService = useAccountService();
|
|
409
472
|
const toaster = (0, import_theme_shared2.useToaster)();
|
|
410
473
|
const currentTenant = (0, import_react_redux.useSelector)(import_core6.selectTenant);
|
|
411
|
-
const [
|
|
474
|
+
const [name, setName] = (0, import_react8.useState)("");
|
|
412
475
|
const [isModalVisible, setIsModalVisible] = (0, import_react8.useState)(false);
|
|
413
|
-
const [
|
|
476
|
+
const [modalBusy, setModalBusy] = (0, import_react8.useState)(false);
|
|
414
477
|
(0, import_react8.useEffect)(() => {
|
|
415
|
-
|
|
478
|
+
setName(currentTenant?.name || "");
|
|
416
479
|
}, [currentTenant]);
|
|
417
480
|
const onSwitch = (0, import_react8.useCallback)(() => {
|
|
418
481
|
setIsModalVisible(true);
|
|
419
482
|
}, []);
|
|
483
|
+
const setTenant = (0, import_react8.useCallback)(
|
|
484
|
+
(tenant) => {
|
|
485
|
+
dispatch(import_core6.sessionActions.setTenant(tenant));
|
|
486
|
+
},
|
|
487
|
+
[dispatch]
|
|
488
|
+
);
|
|
489
|
+
const showError = (0, import_react8.useCallback)(
|
|
490
|
+
(message) => {
|
|
491
|
+
toaster.error(message, t("AbpUi::Error") || "Error");
|
|
492
|
+
},
|
|
493
|
+
[toaster, t]
|
|
494
|
+
);
|
|
420
495
|
const save = (0, import_react8.useCallback)(async () => {
|
|
421
|
-
if (
|
|
422
|
-
|
|
496
|
+
if (name) {
|
|
497
|
+
setModalBusy(true);
|
|
423
498
|
try {
|
|
424
|
-
const { success, tenantId } = await accountService.findTenant(
|
|
499
|
+
const { success, tenantId, name: responseName } = await accountService.findTenant(name);
|
|
425
500
|
if (success) {
|
|
426
|
-
const
|
|
427
|
-
|
|
428
|
-
name: tenantName
|
|
429
|
-
};
|
|
430
|
-
dispatch(import_core6.sessionActions.setTenant(newTenant));
|
|
501
|
+
const tenantName = responseName || name;
|
|
502
|
+
setTenant({ id: tenantId, name: tenantName });
|
|
431
503
|
setIsModalVisible(false);
|
|
432
504
|
} else {
|
|
433
|
-
|
|
434
|
-
t("AbpUiMultiTenancy::GivenTenantIsNotAvailable",
|
|
435
|
-
t("AbpUi::Error") || "Error"
|
|
505
|
+
showError(
|
|
506
|
+
t("AbpUiMultiTenancy::GivenTenantIsNotAvailable", name) || `Tenant "${name}" is not available`
|
|
436
507
|
);
|
|
437
|
-
|
|
508
|
+
setName("");
|
|
438
509
|
}
|
|
439
510
|
} catch (err) {
|
|
440
511
|
const errorMessage = err?.error?.error_description || err?.error?.error?.message || t("AbpUi::DefaultErrorMessage") || "An error occurred";
|
|
441
|
-
|
|
512
|
+
showError(errorMessage);
|
|
442
513
|
} finally {
|
|
443
|
-
|
|
514
|
+
setModalBusy(false);
|
|
444
515
|
}
|
|
445
516
|
} else {
|
|
446
|
-
|
|
517
|
+
setTenant({ id: "", name: "" });
|
|
447
518
|
setIsModalVisible(false);
|
|
448
519
|
}
|
|
449
|
-
}, [
|
|
520
|
+
}, [name, accountService, setTenant, showError, t]);
|
|
450
521
|
const onClose = (0, import_react8.useCallback)(() => {
|
|
451
|
-
|
|
522
|
+
setName(currentTenant?.name || "");
|
|
452
523
|
setIsModalVisible(false);
|
|
453
524
|
}, [currentTenant]);
|
|
454
525
|
const handleSubmit = (0, import_react8.useCallback)(
|
|
@@ -507,7 +578,7 @@ function TenantBox({ containerStyle }) {
|
|
|
507
578
|
{
|
|
508
579
|
colorPalette: "blue",
|
|
509
580
|
onClick: save,
|
|
510
|
-
loading:
|
|
581
|
+
loading: modalBusy,
|
|
511
582
|
loadingText: t("AbpTenantManagement::Save"),
|
|
512
583
|
children: [
|
|
513
584
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CheckIcon, {}),
|
|
@@ -524,8 +595,8 @@ function TenantBox({ containerStyle }) {
|
|
|
524
595
|
{
|
|
525
596
|
id: "tenant-name",
|
|
526
597
|
type: "text",
|
|
527
|
-
value:
|
|
528
|
-
onChange: (e) =>
|
|
598
|
+
value: name,
|
|
599
|
+
onChange: (e) => setName(e.target.value),
|
|
529
600
|
autoFocus: true
|
|
530
601
|
}
|
|
531
602
|
)
|
|
@@ -536,6 +607,7 @@ function TenantBox({ containerStyle }) {
|
|
|
536
607
|
)
|
|
537
608
|
] });
|
|
538
609
|
}
|
|
610
|
+
TenantBox.componentKey = eAccountComponents.TenantBox;
|
|
539
611
|
function CheckIcon() {
|
|
540
612
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
541
613
|
"svg",
|
|
@@ -651,6 +723,7 @@ function LoginForm({
|
|
|
651
723
|
] }) })
|
|
652
724
|
] }) }) }) });
|
|
653
725
|
}
|
|
726
|
+
LoginForm.authWrapperKey = eAccountComponents.AuthWrapper;
|
|
654
727
|
|
|
655
728
|
// src/components/ManageProfile/ManageProfile.tsx
|
|
656
729
|
var import_react15 = require("react");
|
|
@@ -860,6 +933,8 @@ function ManageProfile({
|
|
|
860
933
|
)
|
|
861
934
|
] }) }) });
|
|
862
935
|
}
|
|
936
|
+
ManageProfile.changePasswordKey = eAccountComponents.ChangePassword;
|
|
937
|
+
ManageProfile.personalSettingsKey = eAccountComponents.PersonalSettings;
|
|
863
938
|
|
|
864
939
|
// src/components/RegisterForm/RegisterForm.tsx
|
|
865
940
|
var import_react17 = require("react");
|
|
@@ -1039,6 +1114,7 @@ function RegisterForm({
|
|
|
1039
1114
|
] }) })
|
|
1040
1115
|
] }) }) }) });
|
|
1041
1116
|
}
|
|
1117
|
+
RegisterForm.authWrapperKey = eAccountComponents.AuthWrapper;
|
|
1042
1118
|
|
|
1043
1119
|
// src/pages/LoginPage.tsx
|
|
1044
1120
|
var import_react20 = require("@chakra-ui/react");
|
|
@@ -1081,6 +1157,8 @@ var ACCOUNT_PATHS = {
|
|
|
1081
1157
|
RegisterForm,
|
|
1082
1158
|
RegisterPage,
|
|
1083
1159
|
TenantBox,
|
|
1160
|
+
eAccountComponents,
|
|
1161
|
+
eAccountRouteNames,
|
|
1084
1162
|
useAccountContext,
|
|
1085
1163
|
useAccountOptions,
|
|
1086
1164
|
useAccountService,
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,66 @@
|
|
|
1
|
+
// src/enums/components.ts
|
|
2
|
+
var eAccountComponents = {
|
|
3
|
+
/**
|
|
4
|
+
* Key for the Login component
|
|
5
|
+
*/
|
|
6
|
+
Login: "Account.LoginComponent",
|
|
7
|
+
/**
|
|
8
|
+
* Key for the Register component
|
|
9
|
+
*/
|
|
10
|
+
Register: "Account.RegisterComponent",
|
|
11
|
+
/**
|
|
12
|
+
* Key for the ManageProfile component
|
|
13
|
+
*/
|
|
14
|
+
ManageProfile: "Account.ManageProfileComponent",
|
|
15
|
+
/**
|
|
16
|
+
* Key for the TenantBox component
|
|
17
|
+
*/
|
|
18
|
+
TenantBox: "Account.TenantBoxComponent",
|
|
19
|
+
/**
|
|
20
|
+
* Key for the AuthWrapper component
|
|
21
|
+
*/
|
|
22
|
+
AuthWrapper: "Account.AuthWrapperComponent",
|
|
23
|
+
/**
|
|
24
|
+
* Key for the ChangePassword component
|
|
25
|
+
*/
|
|
26
|
+
ChangePassword: "Account.ChangePasswordComponent",
|
|
27
|
+
/**
|
|
28
|
+
* Key for the PersonalSettings component
|
|
29
|
+
*/
|
|
30
|
+
PersonalSettings: "Account.PersonalSettingsComponent"
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/enums/route-names.ts
|
|
34
|
+
var eAccountRouteNames = {
|
|
35
|
+
/**
|
|
36
|
+
* Route name for Account menu
|
|
37
|
+
*/
|
|
38
|
+
Account: "AbpAccount::Menu:Account",
|
|
39
|
+
/**
|
|
40
|
+
* Route name for Login page
|
|
41
|
+
*/
|
|
42
|
+
Login: "AbpAccount::Login",
|
|
43
|
+
/**
|
|
44
|
+
* Route name for Register page
|
|
45
|
+
*/
|
|
46
|
+
Register: "AbpAccount::Register",
|
|
47
|
+
/**
|
|
48
|
+
* Route name for Manage Profile page
|
|
49
|
+
*/
|
|
50
|
+
ManageProfile: "AbpAccount::ManageYourProfile"
|
|
51
|
+
};
|
|
52
|
+
|
|
1
53
|
// src/services/account.service.ts
|
|
2
54
|
var AccountService = class {
|
|
3
55
|
constructor(rest) {
|
|
4
56
|
this.rest = rest;
|
|
57
|
+
/**
|
|
58
|
+
* The API name used for REST requests.
|
|
59
|
+
* This corresponds to the key in the environment.apis configuration.
|
|
60
|
+
*
|
|
61
|
+
* @since 2.4.0
|
|
62
|
+
*/
|
|
63
|
+
this.apiName = "default";
|
|
5
64
|
}
|
|
6
65
|
/**
|
|
7
66
|
* Find a tenant by name
|
|
@@ -195,7 +254,8 @@ function AuthWrapper({
|
|
|
195
254
|
children,
|
|
196
255
|
mainContent,
|
|
197
256
|
cancelContent,
|
|
198
|
-
enableLocalLogin
|
|
257
|
+
enableLocalLogin,
|
|
258
|
+
isMultiTenancyEnabled = true
|
|
199
259
|
}) {
|
|
200
260
|
const { t } = useLocalization();
|
|
201
261
|
const localLoginSetting = useSetting2(ENABLE_LOCAL_LOGIN_SETTING);
|
|
@@ -208,6 +268,7 @@ function AuthWrapper({
|
|
|
208
268
|
cancelContent && /* @__PURE__ */ jsx2(Box, { textAlign: "center", mt: 4, children: cancelContent })
|
|
209
269
|
] }) }) }) });
|
|
210
270
|
}
|
|
271
|
+
AuthWrapper.tenantBoxKey = eAccountComponents.TenantBox;
|
|
211
272
|
|
|
212
273
|
// src/components/ChangePasswordForm/ChangePasswordForm.tsx
|
|
213
274
|
import { useState as useState2, useEffect } from "react";
|
|
@@ -365,47 +426,55 @@ function TenantBox({ containerStyle }) {
|
|
|
365
426
|
const accountService = useAccountService();
|
|
366
427
|
const toaster = useToaster2();
|
|
367
428
|
const currentTenant = useSelector(selectTenant);
|
|
368
|
-
const [
|
|
429
|
+
const [name, setName] = useState3("");
|
|
369
430
|
const [isModalVisible, setIsModalVisible] = useState3(false);
|
|
370
|
-
const [
|
|
431
|
+
const [modalBusy, setModalBusy] = useState3(false);
|
|
371
432
|
useEffect2(() => {
|
|
372
|
-
|
|
433
|
+
setName(currentTenant?.name || "");
|
|
373
434
|
}, [currentTenant]);
|
|
374
435
|
const onSwitch = useCallback2(() => {
|
|
375
436
|
setIsModalVisible(true);
|
|
376
437
|
}, []);
|
|
438
|
+
const setTenant = useCallback2(
|
|
439
|
+
(tenant) => {
|
|
440
|
+
dispatch(sessionActions.setTenant(tenant));
|
|
441
|
+
},
|
|
442
|
+
[dispatch]
|
|
443
|
+
);
|
|
444
|
+
const showError = useCallback2(
|
|
445
|
+
(message) => {
|
|
446
|
+
toaster.error(message, t("AbpUi::Error") || "Error");
|
|
447
|
+
},
|
|
448
|
+
[toaster, t]
|
|
449
|
+
);
|
|
377
450
|
const save = useCallback2(async () => {
|
|
378
|
-
if (
|
|
379
|
-
|
|
451
|
+
if (name) {
|
|
452
|
+
setModalBusy(true);
|
|
380
453
|
try {
|
|
381
|
-
const { success, tenantId } = await accountService.findTenant(
|
|
454
|
+
const { success, tenantId, name: responseName } = await accountService.findTenant(name);
|
|
382
455
|
if (success) {
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
name: tenantName
|
|
386
|
-
};
|
|
387
|
-
dispatch(sessionActions.setTenant(newTenant));
|
|
456
|
+
const tenantName = responseName || name;
|
|
457
|
+
setTenant({ id: tenantId, name: tenantName });
|
|
388
458
|
setIsModalVisible(false);
|
|
389
459
|
} else {
|
|
390
|
-
|
|
391
|
-
t("AbpUiMultiTenancy::GivenTenantIsNotAvailable",
|
|
392
|
-
t("AbpUi::Error") || "Error"
|
|
460
|
+
showError(
|
|
461
|
+
t("AbpUiMultiTenancy::GivenTenantIsNotAvailable", name) || `Tenant "${name}" is not available`
|
|
393
462
|
);
|
|
394
|
-
|
|
463
|
+
setName("");
|
|
395
464
|
}
|
|
396
465
|
} catch (err) {
|
|
397
466
|
const errorMessage = err?.error?.error_description || err?.error?.error?.message || t("AbpUi::DefaultErrorMessage") || "An error occurred";
|
|
398
|
-
|
|
467
|
+
showError(errorMessage);
|
|
399
468
|
} finally {
|
|
400
|
-
|
|
469
|
+
setModalBusy(false);
|
|
401
470
|
}
|
|
402
471
|
} else {
|
|
403
|
-
|
|
472
|
+
setTenant({ id: "", name: "" });
|
|
404
473
|
setIsModalVisible(false);
|
|
405
474
|
}
|
|
406
|
-
}, [
|
|
475
|
+
}, [name, accountService, setTenant, showError, t]);
|
|
407
476
|
const onClose = useCallback2(() => {
|
|
408
|
-
|
|
477
|
+
setName(currentTenant?.name || "");
|
|
409
478
|
setIsModalVisible(false);
|
|
410
479
|
}, [currentTenant]);
|
|
411
480
|
const handleSubmit = useCallback2(
|
|
@@ -464,7 +533,7 @@ function TenantBox({ containerStyle }) {
|
|
|
464
533
|
{
|
|
465
534
|
colorPalette: "blue",
|
|
466
535
|
onClick: save,
|
|
467
|
-
loading:
|
|
536
|
+
loading: modalBusy,
|
|
468
537
|
loadingText: t("AbpTenantManagement::Save"),
|
|
469
538
|
children: [
|
|
470
539
|
/* @__PURE__ */ jsx4(CheckIcon, {}),
|
|
@@ -481,8 +550,8 @@ function TenantBox({ containerStyle }) {
|
|
|
481
550
|
{
|
|
482
551
|
id: "tenant-name",
|
|
483
552
|
type: "text",
|
|
484
|
-
value:
|
|
485
|
-
onChange: (e) =>
|
|
553
|
+
value: name,
|
|
554
|
+
onChange: (e) => setName(e.target.value),
|
|
486
555
|
autoFocus: true
|
|
487
556
|
}
|
|
488
557
|
)
|
|
@@ -493,6 +562,7 @@ function TenantBox({ containerStyle }) {
|
|
|
493
562
|
)
|
|
494
563
|
] });
|
|
495
564
|
}
|
|
565
|
+
TenantBox.componentKey = eAccountComponents.TenantBox;
|
|
496
566
|
function CheckIcon() {
|
|
497
567
|
return /* @__PURE__ */ jsx4(
|
|
498
568
|
"svg",
|
|
@@ -616,6 +686,7 @@ function LoginForm({
|
|
|
616
686
|
] }) })
|
|
617
687
|
] }) }) }) });
|
|
618
688
|
}
|
|
689
|
+
LoginForm.authWrapperKey = eAccountComponents.AuthWrapper;
|
|
619
690
|
|
|
620
691
|
// src/components/ManageProfile/ManageProfile.tsx
|
|
621
692
|
import { useState as useState5 } from "react";
|
|
@@ -825,6 +896,8 @@ function ManageProfile({
|
|
|
825
896
|
)
|
|
826
897
|
] }) }) });
|
|
827
898
|
}
|
|
899
|
+
ManageProfile.changePasswordKey = eAccountComponents.ChangePassword;
|
|
900
|
+
ManageProfile.personalSettingsKey = eAccountComponents.PersonalSettings;
|
|
828
901
|
|
|
829
902
|
// src/components/RegisterForm/RegisterForm.tsx
|
|
830
903
|
import { useState as useState6, useEffect as useEffect4 } from "react";
|
|
@@ -1012,6 +1085,7 @@ function RegisterForm({
|
|
|
1012
1085
|
] }) })
|
|
1013
1086
|
] }) }) }) });
|
|
1014
1087
|
}
|
|
1088
|
+
RegisterForm.authWrapperKey = eAccountComponents.AuthWrapper;
|
|
1015
1089
|
|
|
1016
1090
|
// src/pages/LoginPage.tsx
|
|
1017
1091
|
import { Container as Container5, Center } from "@chakra-ui/react";
|
|
@@ -1053,6 +1127,8 @@ export {
|
|
|
1053
1127
|
RegisterForm,
|
|
1054
1128
|
RegisterPage,
|
|
1055
1129
|
TenantBox,
|
|
1130
|
+
eAccountComponents,
|
|
1131
|
+
eAccountRouteNames,
|
|
1056
1132
|
useAccountContext,
|
|
1057
1133
|
useAccountOptions,
|
|
1058
1134
|
useAccountService,
|
package/dist/models/index.d.ts
CHANGED
|
@@ -132,8 +132,15 @@ export interface RegisterResponse {
|
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
134
|
* Response from tenant lookup API
|
|
135
|
+
*
|
|
136
|
+
* @since 2.7.0 - Added name property
|
|
135
137
|
*/
|
|
136
138
|
export interface TenantIdResponse {
|
|
137
139
|
success: boolean;
|
|
138
140
|
tenantId: string;
|
|
141
|
+
/**
|
|
142
|
+
* The name of the tenant
|
|
143
|
+
* @since 2.7.0
|
|
144
|
+
*/
|
|
145
|
+
name?: string;
|
|
139
146
|
}
|
|
@@ -7,9 +7,17 @@ import type { RegisterRequest, RegisterResponse, TenantIdResponse } from '../mod
|
|
|
7
7
|
* Provides methods for tenant lookup and user registration.
|
|
8
8
|
*
|
|
9
9
|
* @since 0.9.0
|
|
10
|
+
* @since 2.4.0 - Added apiName property
|
|
10
11
|
*/
|
|
11
12
|
export declare class AccountService {
|
|
12
13
|
private rest;
|
|
14
|
+
/**
|
|
15
|
+
* The API name used for REST requests.
|
|
16
|
+
* This corresponds to the key in the environment.apis configuration.
|
|
17
|
+
*
|
|
18
|
+
* @since 2.4.0
|
|
19
|
+
*/
|
|
20
|
+
apiName: string;
|
|
13
21
|
constructor(rest: RestService);
|
|
14
22
|
/**
|
|
15
23
|
* Find a tenant by name
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abpjs/account",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "ABP Framework Account module for React - Translation of @abp/ng.account",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"react-redux": "^9.0.0",
|
|
54
54
|
"zod": "^3.22.0",
|
|
55
55
|
"react-icons": "^5.0.0",
|
|
56
|
-
"@abpjs/core": "2.
|
|
57
|
-
"@abpjs/theme-shared": "2.
|
|
56
|
+
"@abpjs/core": "2.7.0",
|
|
57
|
+
"@abpjs/theme-shared": "2.7.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@abp/ng.account": "2.
|
|
60
|
+
"@abp/ng.account": "2.7.0",
|
|
61
61
|
"@reduxjs/toolkit": "^2.0.0",
|
|
62
62
|
"@testing-library/jest-dom": "^6.4.0",
|
|
63
63
|
"@testing-library/react": "^14.2.0",
|