@abpjs/account 2.9.0 → 3.1.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 +1 -1
- package/dist/components/ChangePasswordForm/ChangePasswordForm.d.ts +13 -1
- package/dist/components/ManageProfile/ManageProfile.d.ts +13 -1
- package/dist/config/enums/index.d.ts +6 -0
- package/dist/{enums → config/enums}/route-names.d.ts +5 -1
- package/dist/config/index.d.ts +23 -0
- package/dist/config/providers/index.d.ts +6 -0
- package/dist/config/providers/route.provider.d.ts +55 -0
- package/dist/enums/index.d.ts +2 -1
- package/dist/guards/authentication-flow.guard.d.ts +121 -0
- package/dist/guards/index.d.ts +7 -0
- package/dist/index.d.ts +22 -2
- package/dist/index.js +226 -75
- package/dist/index.mjs +203 -59
- package/dist/models/index.d.ts +7 -14
- package/dist/utils/factory-utils.d.ts +29 -0
- package/dist/utils/index.d.ts +6 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -21,9 +21,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ACCOUNT_PATHS: () => ACCOUNT_PATHS,
|
|
24
|
+
ACCOUNT_ROUTE_PROVIDERS: () => ACCOUNT_ROUTE_PROVIDERS,
|
|
24
25
|
AccountProvider: () => AccountProvider,
|
|
25
26
|
AccountService: () => AccountService,
|
|
26
27
|
AuthWrapper: () => AuthWrapper,
|
|
28
|
+
AuthenticationFlowGuard: () => AuthenticationFlowGuard,
|
|
27
29
|
ChangePasswordForm: () => ChangePasswordForm,
|
|
28
30
|
DEFAULT_REDIRECT_URL: () => DEFAULT_REDIRECT_URL,
|
|
29
31
|
LoginForm: () => LoginForm,
|
|
@@ -33,16 +35,86 @@ __export(index_exports, {
|
|
|
33
35
|
RegisterForm: () => RegisterForm,
|
|
34
36
|
RegisterPage: () => RegisterPage,
|
|
35
37
|
TenantBox: () => TenantBox,
|
|
38
|
+
accountOptionsFactory: () => accountOptionsFactory,
|
|
39
|
+
authenticationFlowGuard: () => authenticationFlowGuard,
|
|
40
|
+
configureRoutes: () => configureRoutes,
|
|
36
41
|
eAccountComponents: () => eAccountComponents,
|
|
37
42
|
eAccountRouteNames: () => eAccountRouteNames,
|
|
43
|
+
initializeAccountRoutes: () => initializeAccountRoutes,
|
|
38
44
|
useAccountContext: () => useAccountContext,
|
|
39
45
|
useAccountOptions: () => useAccountOptions,
|
|
40
46
|
useAccountService: () => useAccountService,
|
|
47
|
+
useAuthenticationFlowGuard: () => useAuthenticationFlowGuard,
|
|
41
48
|
usePasswordFlow: () => usePasswordFlow,
|
|
42
49
|
useSelfRegistrationEnabled: () => useSelfRegistrationEnabled
|
|
43
50
|
});
|
|
44
51
|
module.exports = __toCommonJS(index_exports);
|
|
45
52
|
|
|
53
|
+
// src/config/enums/route-names.ts
|
|
54
|
+
var eAccountRouteNames = {
|
|
55
|
+
/**
|
|
56
|
+
* Route name for Account menu
|
|
57
|
+
*/
|
|
58
|
+
Account: "AbpAccount::Menu:Account",
|
|
59
|
+
/**
|
|
60
|
+
* Route name for Login page
|
|
61
|
+
*/
|
|
62
|
+
Login: "AbpAccount::Login",
|
|
63
|
+
/**
|
|
64
|
+
* Route name for Register page
|
|
65
|
+
*/
|
|
66
|
+
Register: "AbpAccount::Register",
|
|
67
|
+
/**
|
|
68
|
+
* Route name for Manage Profile page
|
|
69
|
+
*/
|
|
70
|
+
ManageProfile: "AbpAccount::ManageYourProfile"
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// src/config/providers/route.provider.ts
|
|
74
|
+
var import_core = require("@abpjs/core");
|
|
75
|
+
function configureRoutes(routes) {
|
|
76
|
+
return () => {
|
|
77
|
+
routes.add([
|
|
78
|
+
{
|
|
79
|
+
path: "/account",
|
|
80
|
+
name: eAccountRouteNames.Account,
|
|
81
|
+
invisible: true,
|
|
82
|
+
layout: import_core.eLayoutType.application,
|
|
83
|
+
order: 1
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
path: "/account/login",
|
|
87
|
+
name: eAccountRouteNames.Login,
|
|
88
|
+
parentName: eAccountRouteNames.Account,
|
|
89
|
+
order: 1
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
path: "/account/register",
|
|
93
|
+
name: eAccountRouteNames.Register,
|
|
94
|
+
parentName: eAccountRouteNames.Account,
|
|
95
|
+
order: 2
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
path: "/account/manage-profile",
|
|
99
|
+
name: eAccountRouteNames.ManageProfile,
|
|
100
|
+
parentName: eAccountRouteNames.Account,
|
|
101
|
+
order: 3
|
|
102
|
+
}
|
|
103
|
+
]);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
var ACCOUNT_ROUTE_PROVIDERS = {
|
|
107
|
+
/**
|
|
108
|
+
* Factory function to configure routes
|
|
109
|
+
*/
|
|
110
|
+
configureRoutes
|
|
111
|
+
};
|
|
112
|
+
function initializeAccountRoutes() {
|
|
113
|
+
const routes = (0, import_core.getRoutesService)();
|
|
114
|
+
const addRoutes = configureRoutes(routes);
|
|
115
|
+
addRoutes();
|
|
116
|
+
}
|
|
117
|
+
|
|
46
118
|
// src/enums/components.ts
|
|
47
119
|
var eAccountComponents = {
|
|
48
120
|
/**
|
|
@@ -75,24 +147,38 @@ var eAccountComponents = {
|
|
|
75
147
|
PersonalSettings: "Account.PersonalSettingsComponent"
|
|
76
148
|
};
|
|
77
149
|
|
|
78
|
-
// src/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
150
|
+
// src/guards/authentication-flow.guard.ts
|
|
151
|
+
function authenticationFlowGuard(options) {
|
|
152
|
+
const { isInternalAuth, initLogin } = options;
|
|
153
|
+
if (isInternalAuth) {
|
|
154
|
+
return { canActivate: true };
|
|
155
|
+
}
|
|
156
|
+
initLogin();
|
|
157
|
+
return {
|
|
158
|
+
canActivate: false,
|
|
159
|
+
reason: "external_auth"
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function useAuthenticationFlowGuard(options) {
|
|
163
|
+
const result = authenticationFlowGuard(options);
|
|
164
|
+
return result.canActivate;
|
|
165
|
+
}
|
|
166
|
+
var AuthenticationFlowGuard = class {
|
|
167
|
+
constructor(isInternalAuth, initLogin) {
|
|
168
|
+
this.isInternalAuth = isInternalAuth;
|
|
169
|
+
this.initLogin = initLogin;
|
|
170
|
+
}
|
|
92
171
|
/**
|
|
93
|
-
*
|
|
172
|
+
* Check if navigation should be allowed
|
|
173
|
+
* @returns Whether navigation is allowed
|
|
94
174
|
*/
|
|
95
|
-
|
|
175
|
+
canActivate() {
|
|
176
|
+
if (this.isInternalAuth) {
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
this.initLogin();
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
96
182
|
};
|
|
97
183
|
|
|
98
184
|
// src/services/account.service.ts
|
|
@@ -133,6 +219,14 @@ var AccountService = class {
|
|
|
133
219
|
}
|
|
134
220
|
};
|
|
135
221
|
|
|
222
|
+
// src/utils/factory-utils.ts
|
|
223
|
+
function accountOptionsFactory(options) {
|
|
224
|
+
return {
|
|
225
|
+
redirectUrl: "/",
|
|
226
|
+
...options
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
136
230
|
// src/providers/AccountProvider.tsx
|
|
137
231
|
var import_react = require("react");
|
|
138
232
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -170,11 +264,11 @@ function useAccountOptions() {
|
|
|
170
264
|
|
|
171
265
|
// src/hooks/usePasswordFlow.ts
|
|
172
266
|
var import_react2 = require("react");
|
|
173
|
-
var
|
|
267
|
+
var import_core2 = require("@abpjs/core");
|
|
174
268
|
var import_react_router_dom = require("react-router-dom");
|
|
175
269
|
function usePasswordFlow() {
|
|
176
|
-
const { store, axiosInstance, applicationConfigurationService, userManager } = (0,
|
|
177
|
-
const config = (0,
|
|
270
|
+
const { store, axiosInstance, applicationConfigurationService, userManager } = (0, import_core2.useAbp)();
|
|
271
|
+
const config = (0, import_core2.useConfig)();
|
|
178
272
|
const options = useAccountOptions();
|
|
179
273
|
const navigate = (0, import_react_router_dom.useNavigate)();
|
|
180
274
|
const [isLoading, setIsLoading] = (0, import_react2.useState)(false);
|
|
@@ -236,7 +330,7 @@ function usePasswordFlow() {
|
|
|
236
330
|
}
|
|
237
331
|
}
|
|
238
332
|
const appConfig = await applicationConfigurationService.getConfiguration();
|
|
239
|
-
store.dispatch(
|
|
333
|
+
store.dispatch(import_core2.configActions.setApplicationConfiguration(appConfig));
|
|
240
334
|
const redirectUrl = window.history.state?.redirectUrl || options.redirectUrl;
|
|
241
335
|
navigate(redirectUrl);
|
|
242
336
|
setIsLoading(false);
|
|
@@ -273,17 +367,17 @@ function usePasswordFlow() {
|
|
|
273
367
|
|
|
274
368
|
// src/hooks/useAccountService.ts
|
|
275
369
|
var import_react3 = require("react");
|
|
276
|
-
var
|
|
370
|
+
var import_core3 = require("@abpjs/core");
|
|
277
371
|
function useAccountService() {
|
|
278
|
-
const restService = (0,
|
|
372
|
+
const restService = (0, import_core3.useRestService)();
|
|
279
373
|
return (0, import_react3.useMemo)(() => new AccountService(restService), [restService]);
|
|
280
374
|
}
|
|
281
375
|
|
|
282
376
|
// src/hooks/useSelfRegistration.ts
|
|
283
|
-
var
|
|
377
|
+
var import_core4 = require("@abpjs/core");
|
|
284
378
|
var SELF_REGISTRATION_SETTING = "Abp.Account.IsSelfRegistrationEnabled";
|
|
285
379
|
function useSelfRegistrationEnabled() {
|
|
286
|
-
const setting = (0,
|
|
380
|
+
const setting = (0, import_core4.useSetting)(SELF_REGISTRATION_SETTING);
|
|
287
381
|
if (setting === void 0 || setting === null) {
|
|
288
382
|
return true;
|
|
289
383
|
}
|
|
@@ -292,7 +386,7 @@ function useSelfRegistrationEnabled() {
|
|
|
292
386
|
|
|
293
387
|
// src/components/AuthWrapper/AuthWrapper.tsx
|
|
294
388
|
var import_react4 = require("@chakra-ui/react");
|
|
295
|
-
var
|
|
389
|
+
var import_core5 = require("@abpjs/core");
|
|
296
390
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
297
391
|
var ENABLE_LOCAL_LOGIN_SETTING = "Abp.Account.EnableLocalLogin";
|
|
298
392
|
function AuthWrapper({
|
|
@@ -300,10 +394,10 @@ function AuthWrapper({
|
|
|
300
394
|
mainContent,
|
|
301
395
|
cancelContent,
|
|
302
396
|
enableLocalLogin,
|
|
303
|
-
isMultiTenancyEnabled = true
|
|
397
|
+
isMultiTenancyEnabled: _isMultiTenancyEnabled = true
|
|
304
398
|
}) {
|
|
305
|
-
const { t } = (0,
|
|
306
|
-
const localLoginSetting = (0,
|
|
399
|
+
const { t } = (0, import_core5.useLocalization)();
|
|
400
|
+
const localLoginSetting = (0, import_core5.useSetting)(ENABLE_LOCAL_LOGIN_SETTING);
|
|
307
401
|
const isLocalLoginEnabled = enableLocalLogin ?? (localLoginSetting === void 0 || localLoginSetting === null ? true : localLoginSetting.toLowerCase() === "true");
|
|
308
402
|
if (!isLocalLoginEnabled) {
|
|
309
403
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react4.Flex, { height: "full", flex: "1", className: "auth-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react4.Box, { flex: "1", py: { base: "24", md: "32" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react4.Container, { maxW: "md", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react4.Stack, { gap: "8", textAlign: "center", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react4.Text, { fontSize: "lg", color: "fg.muted", children: t("AbpAccount::LocalLoginDisabledMessage") || "Local login is disabled. Please use an external login provider." }) }) }) }) });
|
|
@@ -320,7 +414,7 @@ var import_react5 = require("react");
|
|
|
320
414
|
var import_react_hook_form = require("react-hook-form");
|
|
321
415
|
var import_zod = require("@hookform/resolvers/zod");
|
|
322
416
|
var import_zod2 = require("zod");
|
|
323
|
-
var
|
|
417
|
+
var import_core6 = require("@abpjs/core");
|
|
324
418
|
var import_theme_shared = require("@abpjs/theme-shared");
|
|
325
419
|
var import_react6 = require("@chakra-ui/react");
|
|
326
420
|
var import_react7 = require("@chakra-ui/react");
|
|
@@ -332,31 +426,58 @@ var passwordValidation = {
|
|
|
332
426
|
hasNumber: /[0-9]/,
|
|
333
427
|
hasSpecial: /[!@#$%^&*(),.?":{}|<>]/
|
|
334
428
|
};
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
429
|
+
function createChangePasswordSchema(hideCurrentPassword) {
|
|
430
|
+
const baseSchema = {
|
|
431
|
+
newPassword: import_zod2.z.string().min(6, "Password must be at least 6 characters").max(32, "Password must be at most 32 characters").refine(
|
|
432
|
+
(val) => passwordValidation.hasLowercase.test(val),
|
|
433
|
+
"Password must contain at least one lowercase letter"
|
|
434
|
+
).refine(
|
|
435
|
+
(val) => passwordValidation.hasUppercase.test(val),
|
|
436
|
+
"Password must contain at least one uppercase letter"
|
|
437
|
+
).refine(
|
|
438
|
+
(val) => passwordValidation.hasNumber.test(val),
|
|
439
|
+
"Password must contain at least one number"
|
|
440
|
+
).refine(
|
|
441
|
+
(val) => passwordValidation.hasSpecial.test(val),
|
|
442
|
+
"Password must contain at least one special character"
|
|
443
|
+
),
|
|
444
|
+
confirmNewPassword: import_zod2.z.string().min(1, "Confirm password is required")
|
|
445
|
+
};
|
|
446
|
+
const schema = hideCurrentPassword ? import_zod2.z.object({
|
|
447
|
+
currentPassword: import_zod2.z.string().optional(),
|
|
448
|
+
...baseSchema
|
|
449
|
+
}) : import_zod2.z.object({
|
|
450
|
+
currentPassword: import_zod2.z.string().min(1, "Current password is required"),
|
|
451
|
+
...baseSchema
|
|
452
|
+
});
|
|
453
|
+
return schema.refine((data) => data.newPassword === data.confirmNewPassword, {
|
|
454
|
+
message: "Passwords do not match",
|
|
455
|
+
path: ["confirmNewPassword"]
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
function ChangePasswordForm({
|
|
459
|
+
onSuccess,
|
|
460
|
+
onError,
|
|
461
|
+
hideCurrentPassword: hideCurrentPasswordProp
|
|
462
|
+
}) {
|
|
463
|
+
const { t } = (0, import_core6.useLocalization)();
|
|
464
|
+
const { profile, changePassword } = (0, import_core6.useProfile)();
|
|
358
465
|
const toaster = (0, import_theme_shared.useToaster)();
|
|
359
466
|
const [inProgress, setInProgress] = (0, import_react5.useState)(false);
|
|
467
|
+
const [showCurrentPasswordAfterChange, setShowCurrentPasswordAfterChange] = (0, import_react5.useState)(false);
|
|
468
|
+
const shouldHideCurrentPassword = (0, import_react5.useMemo)(() => {
|
|
469
|
+
if (hideCurrentPasswordProp !== void 0) {
|
|
470
|
+
return hideCurrentPasswordProp;
|
|
471
|
+
}
|
|
472
|
+
if (showCurrentPasswordAfterChange) {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
return profile?.hasPassword === false;
|
|
476
|
+
}, [hideCurrentPasswordProp, profile?.hasPassword, showCurrentPasswordAfterChange]);
|
|
477
|
+
const changePasswordSchema = (0, import_react5.useMemo)(
|
|
478
|
+
() => createChangePasswordSchema(shouldHideCurrentPassword),
|
|
479
|
+
[shouldHideCurrentPassword]
|
|
480
|
+
);
|
|
360
481
|
const {
|
|
361
482
|
register,
|
|
362
483
|
handleSubmit,
|
|
@@ -370,13 +491,13 @@ function ChangePasswordForm({ onSuccess, onError }) {
|
|
|
370
491
|
confirmNewPassword: ""
|
|
371
492
|
}
|
|
372
493
|
});
|
|
373
|
-
(0, import_react5.useEffect)(() => {
|
|
374
|
-
}, []);
|
|
375
494
|
const onSubmit = async (data) => {
|
|
376
495
|
setInProgress(true);
|
|
377
496
|
try {
|
|
378
497
|
await changePassword({
|
|
379
|
-
currentPassword
|
|
498
|
+
// Only include currentPassword if not hidden
|
|
499
|
+
// v3.1.0: Support for users without password (social login)
|
|
500
|
+
...!shouldHideCurrentPassword && data.currentPassword ? { currentPassword: data.currentPassword } : {},
|
|
380
501
|
newPassword: data.newPassword
|
|
381
502
|
});
|
|
382
503
|
toaster.success(
|
|
@@ -384,6 +505,9 @@ function ChangePasswordForm({ onSuccess, onError }) {
|
|
|
384
505
|
t("AbpAccount::Success") || "Success"
|
|
385
506
|
);
|
|
386
507
|
reset();
|
|
508
|
+
if (shouldHideCurrentPassword) {
|
|
509
|
+
setShowCurrentPasswordAfterChange(true);
|
|
510
|
+
}
|
|
387
511
|
onSuccess?.();
|
|
388
512
|
} catch (err) {
|
|
389
513
|
const errorMessage = err?.error?.error_description || err?.error?.error?.message || t("AbpAccount::DefaultErrorMessage") || "An error occurred";
|
|
@@ -394,7 +518,7 @@ function ChangePasswordForm({ onSuccess, onError }) {
|
|
|
394
518
|
}
|
|
395
519
|
};
|
|
396
520
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("form", { onSubmit: handleSubmit(onSubmit), noValidate: true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react6.Stack, { gap: "5", children: [
|
|
397
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react7.Field.Root, { invalid: !!errors.currentPassword, children: [
|
|
521
|
+
!shouldHideCurrentPassword && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react7.Field.Root, { invalid: !!errors.currentPassword, children: [
|
|
398
522
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react7.Field.Label, { children: t("AbpAccount::CurrentPassword") }),
|
|
399
523
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react7.InputGroup, { startElement: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lu.LuLock, {}), width: "full", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
400
524
|
import_react6.Input,
|
|
@@ -454,23 +578,23 @@ var import_react_hook_form2 = require("react-hook-form");
|
|
|
454
578
|
var import_zod3 = require("@hookform/resolvers/zod");
|
|
455
579
|
var import_zod4 = require("zod");
|
|
456
580
|
var import_react_router_dom2 = require("react-router-dom");
|
|
457
|
-
var
|
|
581
|
+
var import_core8 = require("@abpjs/core");
|
|
458
582
|
var import_theme_shared3 = require("@abpjs/theme-shared");
|
|
459
583
|
var import_react10 = require("@chakra-ui/react");
|
|
460
584
|
|
|
461
585
|
// src/components/TenantBox/TenantBox.tsx
|
|
462
586
|
var import_react8 = require("react");
|
|
463
587
|
var import_react_redux = require("react-redux");
|
|
464
|
-
var
|
|
588
|
+
var import_core7 = require("@abpjs/core");
|
|
465
589
|
var import_theme_shared2 = require("@abpjs/theme-shared");
|
|
466
590
|
var import_react9 = require("@chakra-ui/react");
|
|
467
591
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
468
592
|
function TenantBox({ containerStyle }) {
|
|
469
|
-
const { t } = (0,
|
|
593
|
+
const { t } = (0, import_core7.useLocalization)();
|
|
470
594
|
const dispatch = (0, import_react_redux.useDispatch)();
|
|
471
595
|
const accountService = useAccountService();
|
|
472
596
|
const toaster = (0, import_theme_shared2.useToaster)();
|
|
473
|
-
const currentTenant = (0, import_react_redux.useSelector)(
|
|
597
|
+
const currentTenant = (0, import_react_redux.useSelector)(import_core7.selectTenant);
|
|
474
598
|
const [name, setName] = (0, import_react8.useState)("");
|
|
475
599
|
const [isModalVisible, setIsModalVisible] = (0, import_react8.useState)(false);
|
|
476
600
|
const [modalBusy, setModalBusy] = (0, import_react8.useState)(false);
|
|
@@ -482,7 +606,7 @@ function TenantBox({ containerStyle }) {
|
|
|
482
606
|
}, []);
|
|
483
607
|
const setTenant = (0, import_react8.useCallback)(
|
|
484
608
|
(tenant) => {
|
|
485
|
-
dispatch(
|
|
609
|
+
dispatch(import_core7.sessionActions.setTenant(tenant));
|
|
486
610
|
},
|
|
487
611
|
[dispatch]
|
|
488
612
|
);
|
|
@@ -642,7 +766,7 @@ function LoginForm({
|
|
|
642
766
|
onLoginSuccess,
|
|
643
767
|
onLoginError
|
|
644
768
|
}) {
|
|
645
|
-
const { t } = (0,
|
|
769
|
+
const { t } = (0, import_core8.useLocalization)();
|
|
646
770
|
const { login, isLoading, error, clearError } = usePasswordFlow();
|
|
647
771
|
const isSelfRegistrationEnabled = useSelfRegistrationEnabled();
|
|
648
772
|
const {
|
|
@@ -727,7 +851,7 @@ LoginForm.authWrapperKey = eAccountComponents.AuthWrapper;
|
|
|
727
851
|
|
|
728
852
|
// src/components/ManageProfile/ManageProfile.tsx
|
|
729
853
|
var import_react15 = require("react");
|
|
730
|
-
var
|
|
854
|
+
var import_core10 = require("@abpjs/core");
|
|
731
855
|
var import_react16 = require("@chakra-ui/react");
|
|
732
856
|
|
|
733
857
|
// src/components/PersonalSettingsForm/PersonalSettingsForm.tsx
|
|
@@ -735,7 +859,7 @@ var import_react12 = require("react");
|
|
|
735
859
|
var import_react_hook_form3 = require("react-hook-form");
|
|
736
860
|
var import_zod5 = require("@hookform/resolvers/zod");
|
|
737
861
|
var import_zod6 = require("zod");
|
|
738
|
-
var
|
|
862
|
+
var import_core9 = require("@abpjs/core");
|
|
739
863
|
var import_theme_shared4 = require("@abpjs/theme-shared");
|
|
740
864
|
var import_react13 = require("@chakra-ui/react");
|
|
741
865
|
var import_react14 = require("@chakra-ui/react");
|
|
@@ -749,8 +873,8 @@ var personalSettingsSchema = import_zod6.z.object({
|
|
|
749
873
|
phoneNumber: import_zod6.z.string().max(16, "Phone number must be at most 16 characters").optional()
|
|
750
874
|
});
|
|
751
875
|
function PersonalSettingsForm({ onSuccess, onError }) {
|
|
752
|
-
const { t } = (0,
|
|
753
|
-
const { profile, loading, fetchProfile, updateProfile } = (0,
|
|
876
|
+
const { t } = (0, import_core9.useLocalization)();
|
|
877
|
+
const { profile, loading, fetchProfile, updateProfile } = (0, import_core9.useProfile)();
|
|
754
878
|
const toaster = (0, import_theme_shared4.useToaster)();
|
|
755
879
|
const [inProgress, setInProgress] = (0, import_react12.useState)(false);
|
|
756
880
|
const {
|
|
@@ -893,11 +1017,26 @@ var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
|
893
1017
|
function ManageProfile({
|
|
894
1018
|
defaultTabIndex = 0,
|
|
895
1019
|
onTabChange,
|
|
896
|
-
customTabs
|
|
1020
|
+
customTabs,
|
|
1021
|
+
hideChangePasswordTab: hideChangePasswordTabProp
|
|
897
1022
|
}) {
|
|
898
|
-
const { t } = (0,
|
|
1023
|
+
const { t } = (0, import_core10.useLocalization)();
|
|
1024
|
+
const { profile, loading: profileLoading, fetchProfile } = (0, import_core10.useProfile)();
|
|
1025
|
+
const [isProfileLoaded, setIsProfileLoaded] = (0, import_react15.useState)(false);
|
|
899
1026
|
const [selectedTab, setSelectedTab] = (0, import_react15.useState)(defaultTabIndex);
|
|
900
|
-
|
|
1027
|
+
(0, import_react15.useEffect)(() => {
|
|
1028
|
+
fetchProfile().then(() => {
|
|
1029
|
+
setIsProfileLoaded(true);
|
|
1030
|
+
});
|
|
1031
|
+
}, [fetchProfile]);
|
|
1032
|
+
const shouldHideChangePasswordTab = hideChangePasswordTabProp ?? profile?.isExternal ?? false;
|
|
1033
|
+
(0, import_react15.useEffect)(() => {
|
|
1034
|
+
if (isProfileLoaded && shouldHideChangePasswordTab && selectedTab === 0) {
|
|
1035
|
+
const personalSettingsIndex = 0;
|
|
1036
|
+
setSelectedTab(personalSettingsIndex);
|
|
1037
|
+
}
|
|
1038
|
+
}, [isProfileLoaded, shouldHideChangePasswordTab, selectedTab]);
|
|
1039
|
+
const allTabs = [
|
|
901
1040
|
{
|
|
902
1041
|
id: "personal-settings",
|
|
903
1042
|
label: t("AbpAccount::PersonalSettings") || "Personal Settings",
|
|
@@ -906,9 +1045,11 @@ function ManageProfile({
|
|
|
906
1045
|
{
|
|
907
1046
|
id: "change-password",
|
|
908
1047
|
label: t("AbpAccount::ChangePassword") || "Change Password",
|
|
909
|
-
|
|
1048
|
+
// v3.1.0: Pass hideCurrentPassword based on profile.hasPassword
|
|
1049
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChangePasswordForm, { hideCurrentPassword: profile?.hasPassword === false })
|
|
910
1050
|
}
|
|
911
1051
|
];
|
|
1052
|
+
const defaultTabs = shouldHideChangePasswordTab ? allTabs.filter((tab) => tab.id !== "change-password") : allTabs;
|
|
912
1053
|
const tabs = customTabs || defaultTabs;
|
|
913
1054
|
const handleTabChange = (details) => {
|
|
914
1055
|
const index = tabs.findIndex((tab) => tab.id === details.value);
|
|
@@ -917,6 +1058,9 @@ function ManageProfile({
|
|
|
917
1058
|
onTabChange?.(index);
|
|
918
1059
|
}
|
|
919
1060
|
};
|
|
1061
|
+
if (!isProfileLoaded || profileLoading) {
|
|
1062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react16.Box, { className: "manage-profile", py: { base: "8", md: "12" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react16.Container, { maxW: "2xl", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react16.Center, { minH: "400px", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react16.Spinner, { size: "xl" }) }) }) });
|
|
1063
|
+
}
|
|
920
1064
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react16.Box, { className: "manage-profile", py: { base: "8", md: "12" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react16.Container, { maxW: "2xl", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react16.Stack, { gap: "8", children: [
|
|
921
1065
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react16.Heading, { size: "xl", children: t("AbpAccount::ManageYourAccount") || "Manage Your Account" }),
|
|
922
1066
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
@@ -942,7 +1086,7 @@ var import_react_hook_form4 = require("react-hook-form");
|
|
|
942
1086
|
var import_zod7 = require("@hookform/resolvers/zod");
|
|
943
1087
|
var import_zod8 = require("zod");
|
|
944
1088
|
var import_react_router_dom3 = require("react-router-dom");
|
|
945
|
-
var
|
|
1089
|
+
var import_core11 = require("@abpjs/core");
|
|
946
1090
|
var import_theme_shared5 = require("@abpjs/theme-shared");
|
|
947
1091
|
var import_react18 = require("@chakra-ui/react");
|
|
948
1092
|
var import_react19 = require("@chakra-ui/react");
|
|
@@ -978,12 +1122,12 @@ function RegisterForm({
|
|
|
978
1122
|
onRegisterSuccess,
|
|
979
1123
|
onRegisterError
|
|
980
1124
|
}) {
|
|
981
|
-
const { t } = (0,
|
|
1125
|
+
const { t } = (0, import_core11.useLocalization)();
|
|
982
1126
|
const navigate = (0, import_react_router_dom3.useNavigate)();
|
|
983
1127
|
const accountService = useAccountService();
|
|
984
1128
|
const toaster = (0, import_theme_shared5.useToaster)();
|
|
985
|
-
const userManager = (0,
|
|
986
|
-
const { store, applicationConfigurationService } = (0,
|
|
1129
|
+
const userManager = (0, import_core11.useUserManager)();
|
|
1130
|
+
const { store, applicationConfigurationService } = (0, import_core11.useAbp)();
|
|
987
1131
|
const [inProgress, setInProgress] = (0, import_react17.useState)(false);
|
|
988
1132
|
const isSelfRegistrationEnabled = useSelfRegistrationEnabled();
|
|
989
1133
|
(0, import_react17.useEffect)(() => {
|
|
@@ -1020,7 +1164,7 @@ function RegisterForm({
|
|
|
1020
1164
|
password: newUser.password
|
|
1021
1165
|
});
|
|
1022
1166
|
const config = await applicationConfigurationService.getConfiguration();
|
|
1023
|
-
store.dispatch(
|
|
1167
|
+
store.dispatch(import_core11.configActions.setApplicationConfiguration(config));
|
|
1024
1168
|
navigate("/");
|
|
1025
1169
|
onRegisterSuccess?.();
|
|
1026
1170
|
} catch (loginErr) {
|
|
@@ -1145,9 +1289,11 @@ var ACCOUNT_PATHS = {
|
|
|
1145
1289
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1146
1290
|
0 && (module.exports = {
|
|
1147
1291
|
ACCOUNT_PATHS,
|
|
1292
|
+
ACCOUNT_ROUTE_PROVIDERS,
|
|
1148
1293
|
AccountProvider,
|
|
1149
1294
|
AccountService,
|
|
1150
1295
|
AuthWrapper,
|
|
1296
|
+
AuthenticationFlowGuard,
|
|
1151
1297
|
ChangePasswordForm,
|
|
1152
1298
|
DEFAULT_REDIRECT_URL,
|
|
1153
1299
|
LoginForm,
|
|
@@ -1157,11 +1303,16 @@ var ACCOUNT_PATHS = {
|
|
|
1157
1303
|
RegisterForm,
|
|
1158
1304
|
RegisterPage,
|
|
1159
1305
|
TenantBox,
|
|
1306
|
+
accountOptionsFactory,
|
|
1307
|
+
authenticationFlowGuard,
|
|
1308
|
+
configureRoutes,
|
|
1160
1309
|
eAccountComponents,
|
|
1161
1310
|
eAccountRouteNames,
|
|
1311
|
+
initializeAccountRoutes,
|
|
1162
1312
|
useAccountContext,
|
|
1163
1313
|
useAccountOptions,
|
|
1164
1314
|
useAccountService,
|
|
1315
|
+
useAuthenticationFlowGuard,
|
|
1165
1316
|
usePasswordFlow,
|
|
1166
1317
|
useSelfRegistrationEnabled
|
|
1167
1318
|
});
|