@abpjs/account 1.0.0 → 2.0.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 +50 -0
- package/dist/components/AuthWrapper/index.d.ts +1 -0
- package/dist/components/ChangePasswordForm/ChangePasswordForm.d.ts +31 -0
- package/dist/components/ChangePasswordForm/index.d.ts +1 -0
- package/dist/components/LoginForm/LoginForm.d.ts +2 -0
- package/dist/components/ManageProfile/ManageProfile.d.ts +46 -0
- package/dist/components/ManageProfile/index.d.ts +1 -0
- package/dist/components/PersonalSettingsForm/PersonalSettingsForm.d.ts +31 -0
- package/dist/components/PersonalSettingsForm/index.d.ts +1 -0
- package/dist/components/RegisterForm/RegisterForm.d.ts +1 -0
- package/dist/components/index.d.ts +5 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useSelfRegistration.d.ts +24 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +539 -168
- package/dist/index.mjs +531 -164
- package/dist/models/index.d.ts +56 -0
- package/dist/routes/index.d.ts +2 -15
- package/package.json +6 -5
package/dist/index.mjs
CHANGED
|
@@ -175,23 +175,200 @@ function useAccountService() {
|
|
|
175
175
|
return useMemo2(() => new AccountService(restService), [restService]);
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
// src/hooks/useSelfRegistration.ts
|
|
179
|
+
import { useSetting } from "@abpjs/core";
|
|
180
|
+
var SELF_REGISTRATION_SETTING = "Abp.Account.IsSelfRegistrationEnabled";
|
|
181
|
+
function useSelfRegistrationEnabled() {
|
|
182
|
+
const setting = useSetting(SELF_REGISTRATION_SETTING);
|
|
183
|
+
if (setting === void 0 || setting === null) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
return setting.toLowerCase() === "true";
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// src/components/AuthWrapper/AuthWrapper.tsx
|
|
190
|
+
import { Box, Container, Stack, Flex, Text } from "@chakra-ui/react";
|
|
191
|
+
import { useLocalization, useSetting as useSetting2 } from "@abpjs/core";
|
|
192
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
193
|
+
var ENABLE_LOCAL_LOGIN_SETTING = "Abp.Account.EnableLocalLogin";
|
|
194
|
+
function AuthWrapper({
|
|
195
|
+
children,
|
|
196
|
+
mainContent,
|
|
197
|
+
cancelContent,
|
|
198
|
+
enableLocalLogin
|
|
199
|
+
}) {
|
|
200
|
+
const { t } = useLocalization();
|
|
201
|
+
const localLoginSetting = useSetting2(ENABLE_LOCAL_LOGIN_SETTING);
|
|
202
|
+
const isLocalLoginEnabled = enableLocalLogin ?? (localLoginSetting === void 0 || localLoginSetting === null ? true : localLoginSetting.toLowerCase() === "true");
|
|
203
|
+
if (!isLocalLoginEnabled) {
|
|
204
|
+
return /* @__PURE__ */ jsx2(Flex, { height: "full", flex: "1", className: "auth-wrapper", children: /* @__PURE__ */ jsx2(Box, { flex: "1", py: { base: "24", md: "32" }, children: /* @__PURE__ */ jsx2(Container, { maxW: "md", children: /* @__PURE__ */ jsx2(Stack, { gap: "8", textAlign: "center", children: /* @__PURE__ */ jsx2(Text, { fontSize: "lg", color: "fg.muted", children: t("AbpAccount::LocalLoginDisabledMessage") || "Local login is disabled. Please use an external login provider." }) }) }) }) });
|
|
205
|
+
}
|
|
206
|
+
return /* @__PURE__ */ jsx2(Flex, { height: "full", flex: "1", className: "auth-wrapper", children: /* @__PURE__ */ jsx2(Box, { flex: "1", py: { base: "24", md: "32" }, children: /* @__PURE__ */ jsx2(Container, { maxW: "md", children: /* @__PURE__ */ jsxs(Stack, { gap: "8", children: [
|
|
207
|
+
mainContent || children,
|
|
208
|
+
cancelContent && /* @__PURE__ */ jsx2(Box, { textAlign: "center", mt: 4, children: cancelContent })
|
|
209
|
+
] }) }) }) });
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// src/components/ChangePasswordForm/ChangePasswordForm.tsx
|
|
213
|
+
import { useState as useState2, useEffect } from "react";
|
|
214
|
+
import { useForm } from "react-hook-form";
|
|
215
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
216
|
+
import { z } from "zod";
|
|
217
|
+
import { useLocalization as useLocalization2, useProfile } from "@abpjs/core";
|
|
218
|
+
import { Button, useToaster } from "@abpjs/theme-shared";
|
|
219
|
+
import { Input, Stack as Stack2 } from "@chakra-ui/react";
|
|
220
|
+
import { Field, InputGroup } from "@chakra-ui/react";
|
|
221
|
+
import { LuLock } from "react-icons/lu";
|
|
222
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
223
|
+
var passwordValidation = {
|
|
224
|
+
hasLowercase: /[a-z]/,
|
|
225
|
+
hasUppercase: /[A-Z]/,
|
|
226
|
+
hasNumber: /[0-9]/,
|
|
227
|
+
hasSpecial: /[!@#$%^&*(),.?":{}|<>]/
|
|
228
|
+
};
|
|
229
|
+
var changePasswordSchema = z.object({
|
|
230
|
+
currentPassword: z.string().min(1, "Current password is required"),
|
|
231
|
+
newPassword: z.string().min(6, "Password must be at least 6 characters").max(32, "Password must be at most 32 characters").refine(
|
|
232
|
+
(val) => passwordValidation.hasLowercase.test(val),
|
|
233
|
+
"Password must contain at least one lowercase letter"
|
|
234
|
+
).refine(
|
|
235
|
+
(val) => passwordValidation.hasUppercase.test(val),
|
|
236
|
+
"Password must contain at least one uppercase letter"
|
|
237
|
+
).refine(
|
|
238
|
+
(val) => passwordValidation.hasNumber.test(val),
|
|
239
|
+
"Password must contain at least one number"
|
|
240
|
+
).refine(
|
|
241
|
+
(val) => passwordValidation.hasSpecial.test(val),
|
|
242
|
+
"Password must contain at least one special character"
|
|
243
|
+
),
|
|
244
|
+
confirmNewPassword: z.string().min(1, "Confirm password is required")
|
|
245
|
+
}).refine((data) => data.newPassword === data.confirmNewPassword, {
|
|
246
|
+
message: "Passwords do not match",
|
|
247
|
+
path: ["confirmNewPassword"]
|
|
248
|
+
});
|
|
249
|
+
function ChangePasswordForm({ onSuccess, onError }) {
|
|
250
|
+
const { t } = useLocalization2();
|
|
251
|
+
const { changePassword } = useProfile();
|
|
252
|
+
const toaster = useToaster();
|
|
253
|
+
const [inProgress, setInProgress] = useState2(false);
|
|
254
|
+
const {
|
|
255
|
+
register,
|
|
256
|
+
handleSubmit,
|
|
257
|
+
reset,
|
|
258
|
+
formState: { errors }
|
|
259
|
+
} = useForm({
|
|
260
|
+
resolver: zodResolver(changePasswordSchema),
|
|
261
|
+
defaultValues: {
|
|
262
|
+
currentPassword: "",
|
|
263
|
+
newPassword: "",
|
|
264
|
+
confirmNewPassword: ""
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
useEffect(() => {
|
|
268
|
+
}, []);
|
|
269
|
+
const onSubmit = async (data) => {
|
|
270
|
+
setInProgress(true);
|
|
271
|
+
try {
|
|
272
|
+
await changePassword({
|
|
273
|
+
currentPassword: data.currentPassword,
|
|
274
|
+
newPassword: data.newPassword
|
|
275
|
+
});
|
|
276
|
+
toaster.success(
|
|
277
|
+
t("AbpAccount::PasswordChangedMessage") || "Your password has been changed successfully.",
|
|
278
|
+
t("AbpAccount::Success") || "Success"
|
|
279
|
+
);
|
|
280
|
+
reset();
|
|
281
|
+
onSuccess?.();
|
|
282
|
+
} catch (err) {
|
|
283
|
+
const errorMessage = err?.error?.error_description || err?.error?.error?.message || t("AbpAccount::DefaultErrorMessage") || "An error occurred";
|
|
284
|
+
toaster.error(errorMessage, t("AbpUi::Error") || "Error", { life: 7e3 });
|
|
285
|
+
onError?.(errorMessage);
|
|
286
|
+
} finally {
|
|
287
|
+
setInProgress(false);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
return /* @__PURE__ */ jsx3("form", { onSubmit: handleSubmit(onSubmit), noValidate: true, children: /* @__PURE__ */ jsxs2(Stack2, { gap: "5", children: [
|
|
291
|
+
/* @__PURE__ */ jsxs2(Field.Root, { invalid: !!errors.currentPassword, children: [
|
|
292
|
+
/* @__PURE__ */ jsx3(Field.Label, { children: t("AbpAccount::CurrentPassword") }),
|
|
293
|
+
/* @__PURE__ */ jsx3(InputGroup, { startElement: /* @__PURE__ */ jsx3(LuLock, {}), width: "full", children: /* @__PURE__ */ jsx3(
|
|
294
|
+
Input,
|
|
295
|
+
{
|
|
296
|
+
id: "current-password",
|
|
297
|
+
type: "password",
|
|
298
|
+
autoComplete: "current-password",
|
|
299
|
+
placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",
|
|
300
|
+
...register("currentPassword")
|
|
301
|
+
}
|
|
302
|
+
) }),
|
|
303
|
+
errors.currentPassword && /* @__PURE__ */ jsx3(Field.ErrorText, { children: errors.currentPassword.message })
|
|
304
|
+
] }),
|
|
305
|
+
/* @__PURE__ */ jsxs2(Field.Root, { invalid: !!errors.newPassword, children: [
|
|
306
|
+
/* @__PURE__ */ jsx3(Field.Label, { children: t("AbpAccount::NewPassword") }),
|
|
307
|
+
/* @__PURE__ */ jsx3(InputGroup, { startElement: /* @__PURE__ */ jsx3(LuLock, {}), width: "full", children: /* @__PURE__ */ jsx3(
|
|
308
|
+
Input,
|
|
309
|
+
{
|
|
310
|
+
id: "new-password",
|
|
311
|
+
type: "password",
|
|
312
|
+
autoComplete: "new-password",
|
|
313
|
+
placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",
|
|
314
|
+
...register("newPassword")
|
|
315
|
+
}
|
|
316
|
+
) }),
|
|
317
|
+
errors.newPassword && /* @__PURE__ */ jsx3(Field.ErrorText, { children: errors.newPassword.message })
|
|
318
|
+
] }),
|
|
319
|
+
/* @__PURE__ */ jsxs2(Field.Root, { invalid: !!errors.confirmNewPassword, children: [
|
|
320
|
+
/* @__PURE__ */ jsx3(Field.Label, { children: t("AbpAccount::NewPasswordConfirm") }),
|
|
321
|
+
/* @__PURE__ */ jsx3(InputGroup, { startElement: /* @__PURE__ */ jsx3(LuLock, {}), width: "full", children: /* @__PURE__ */ jsx3(
|
|
322
|
+
Input,
|
|
323
|
+
{
|
|
324
|
+
id: "confirm-new-password",
|
|
325
|
+
type: "password",
|
|
326
|
+
autoComplete: "new-password",
|
|
327
|
+
placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",
|
|
328
|
+
...register("confirmNewPassword")
|
|
329
|
+
}
|
|
330
|
+
) }),
|
|
331
|
+
errors.confirmNewPassword && /* @__PURE__ */ jsx3(Field.ErrorText, { children: errors.confirmNewPassword.message })
|
|
332
|
+
] }),
|
|
333
|
+
/* @__PURE__ */ jsx3(
|
|
334
|
+
Button,
|
|
335
|
+
{
|
|
336
|
+
type: "submit",
|
|
337
|
+
colorPalette: "blue",
|
|
338
|
+
loading: inProgress,
|
|
339
|
+
loadingText: t("AbpAccount::Submit"),
|
|
340
|
+
children: t("AbpAccount::Submit")
|
|
341
|
+
}
|
|
342
|
+
)
|
|
343
|
+
] }) });
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// src/components/LoginForm/LoginForm.tsx
|
|
347
|
+
import { useForm as useForm2 } from "react-hook-form";
|
|
348
|
+
import { zodResolver as zodResolver2 } from "@hookform/resolvers/zod";
|
|
349
|
+
import { z as z2 } from "zod";
|
|
350
|
+
import { Link as RouterLink } from "react-router-dom";
|
|
351
|
+
import { useLocalization as useLocalization4 } from "@abpjs/core";
|
|
352
|
+
import { Alert, Button as Button3, Checkbox } from "@abpjs/theme-shared";
|
|
353
|
+
import { Box as Box3, Heading, Input as Input3, Link as Link2, HStack, Show } from "@chakra-ui/react";
|
|
354
|
+
|
|
178
355
|
// src/components/TenantBox/TenantBox.tsx
|
|
179
|
-
import { useState as
|
|
356
|
+
import { useState as useState3, useCallback as useCallback2, useEffect as useEffect2 } from "react";
|
|
180
357
|
import { useDispatch, useSelector } from "react-redux";
|
|
181
|
-
import { useLocalization, sessionActions, selectTenant } from "@abpjs/core";
|
|
182
|
-
import { Modal, Button, useToaster } from "@abpjs/theme-shared";
|
|
183
|
-
import { Box, Text, Link, Input, VStack } from "@chakra-ui/react";
|
|
184
|
-
import { Fragment, jsx as
|
|
358
|
+
import { useLocalization as useLocalization3, sessionActions, selectTenant } from "@abpjs/core";
|
|
359
|
+
import { Modal, Button as Button2, useToaster as useToaster2 } from "@abpjs/theme-shared";
|
|
360
|
+
import { Box as Box2, Text as Text2, Link, Input as Input2, VStack } from "@chakra-ui/react";
|
|
361
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
185
362
|
function TenantBox({ containerStyle }) {
|
|
186
|
-
const { t } =
|
|
363
|
+
const { t } = useLocalization3();
|
|
187
364
|
const dispatch = useDispatch();
|
|
188
365
|
const accountService = useAccountService();
|
|
189
|
-
const toaster =
|
|
366
|
+
const toaster = useToaster2();
|
|
190
367
|
const currentTenant = useSelector(selectTenant);
|
|
191
|
-
const [tenantName, setTenantName] =
|
|
192
|
-
const [isModalVisible, setIsModalVisible] =
|
|
193
|
-
const [
|
|
194
|
-
|
|
368
|
+
const [tenantName, setTenantName] = useState3("");
|
|
369
|
+
const [isModalVisible, setIsModalVisible] = useState3(false);
|
|
370
|
+
const [inProgress, setInProgress] = useState3(false);
|
|
371
|
+
useEffect2(() => {
|
|
195
372
|
setTenantName(currentTenant?.name || "");
|
|
196
373
|
}, [currentTenant]);
|
|
197
374
|
const onSwitch = useCallback2(() => {
|
|
@@ -199,7 +376,7 @@ function TenantBox({ containerStyle }) {
|
|
|
199
376
|
}, []);
|
|
200
377
|
const save = useCallback2(async () => {
|
|
201
378
|
if (tenantName) {
|
|
202
|
-
|
|
379
|
+
setInProgress(true);
|
|
203
380
|
try {
|
|
204
381
|
const { success, tenantId } = await accountService.findTenant(tenantName);
|
|
205
382
|
if (success) {
|
|
@@ -220,7 +397,7 @@ function TenantBox({ containerStyle }) {
|
|
|
220
397
|
const errorMessage = err?.error?.error_description || err?.error?.error?.message || t("AbpUi::DefaultErrorMessage") || "An error occurred";
|
|
221
398
|
toaster.error(errorMessage, t("AbpUi::Error") || "Error");
|
|
222
399
|
} finally {
|
|
223
|
-
|
|
400
|
+
setInProgress(false);
|
|
224
401
|
}
|
|
225
402
|
} else {
|
|
226
403
|
dispatch(sessionActions.setTenant({ id: "", name: "" }));
|
|
@@ -238,9 +415,9 @@ function TenantBox({ containerStyle }) {
|
|
|
238
415
|
},
|
|
239
416
|
[save]
|
|
240
417
|
);
|
|
241
|
-
return /* @__PURE__ */
|
|
242
|
-
/* @__PURE__ */
|
|
243
|
-
|
|
418
|
+
return /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
419
|
+
/* @__PURE__ */ jsxs3(
|
|
420
|
+
Box2,
|
|
244
421
|
{
|
|
245
422
|
className: "tenant-switch-box",
|
|
246
423
|
bg: "gray.100",
|
|
@@ -251,14 +428,14 @@ function TenantBox({ containerStyle }) {
|
|
|
251
428
|
borderRadius: "md",
|
|
252
429
|
style: containerStyle,
|
|
253
430
|
children: [
|
|
254
|
-
/* @__PURE__ */
|
|
431
|
+
/* @__PURE__ */ jsxs3(Text2, { as: "span", color: "gray.600", children: [
|
|
255
432
|
t("AbpUiMultiTenancy::Tenant"),
|
|
256
433
|
":",
|
|
257
434
|
" "
|
|
258
435
|
] }),
|
|
259
|
-
/* @__PURE__ */
|
|
436
|
+
/* @__PURE__ */ jsx4(Text2, { as: "strong", children: /* @__PURE__ */ jsx4(Text2, { as: "i", children: currentTenant?.name || t("AbpUiMultiTenancy::NotSelected") }) }),
|
|
260
437
|
" (",
|
|
261
|
-
/* @__PURE__ */
|
|
438
|
+
/* @__PURE__ */ jsx4(
|
|
262
439
|
Link,
|
|
263
440
|
{
|
|
264
441
|
id: "abp-tenant-switch-link",
|
|
@@ -273,34 +450,34 @@ function TenantBox({ containerStyle }) {
|
|
|
273
450
|
]
|
|
274
451
|
}
|
|
275
452
|
),
|
|
276
|
-
/* @__PURE__ */
|
|
453
|
+
/* @__PURE__ */ jsx4(
|
|
277
454
|
Modal,
|
|
278
455
|
{
|
|
279
456
|
visible: isModalVisible,
|
|
280
457
|
onVisibleChange: setIsModalVisible,
|
|
281
458
|
size: "md",
|
|
282
459
|
header: t("AbpUiMultiTenancy::SwitchTenant") || "Switch Tenant",
|
|
283
|
-
footer: /* @__PURE__ */
|
|
284
|
-
/* @__PURE__ */
|
|
285
|
-
/* @__PURE__ */
|
|
286
|
-
|
|
460
|
+
footer: /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
461
|
+
/* @__PURE__ */ jsx4(Button2, { variant: "ghost", colorPalette: "gray", onClick: onClose, children: t("AbpTenantManagement::Cancel") }),
|
|
462
|
+
/* @__PURE__ */ jsxs3(
|
|
463
|
+
Button2,
|
|
287
464
|
{
|
|
288
465
|
colorPalette: "blue",
|
|
289
466
|
onClick: save,
|
|
290
|
-
loading:
|
|
467
|
+
loading: inProgress,
|
|
291
468
|
loadingText: t("AbpTenantManagement::Save"),
|
|
292
469
|
children: [
|
|
293
|
-
/* @__PURE__ */
|
|
470
|
+
/* @__PURE__ */ jsx4(CheckIcon, {}),
|
|
294
471
|
t("AbpTenantManagement::Save")
|
|
295
472
|
]
|
|
296
473
|
}
|
|
297
474
|
)
|
|
298
475
|
] }),
|
|
299
|
-
children: /* @__PURE__ */
|
|
300
|
-
/* @__PURE__ */
|
|
301
|
-
/* @__PURE__ */
|
|
302
|
-
/* @__PURE__ */
|
|
303
|
-
|
|
476
|
+
children: /* @__PURE__ */ jsx4("form", { onSubmit: handleSubmit, children: /* @__PURE__ */ jsxs3(VStack, { gap: 4, align: "stretch", children: [
|
|
477
|
+
/* @__PURE__ */ jsxs3(Box2, { children: [
|
|
478
|
+
/* @__PURE__ */ jsx4(Text2, { as: "label", mb: 1, display: "block", children: t("AbpUiMultiTenancy::Name") }),
|
|
479
|
+
/* @__PURE__ */ jsx4(
|
|
480
|
+
Input2,
|
|
304
481
|
{
|
|
305
482
|
id: "tenant-name",
|
|
306
483
|
type: "text",
|
|
@@ -310,14 +487,14 @@ function TenantBox({ containerStyle }) {
|
|
|
310
487
|
}
|
|
311
488
|
)
|
|
312
489
|
] }),
|
|
313
|
-
/* @__PURE__ */
|
|
490
|
+
/* @__PURE__ */ jsx4(Text2, { fontSize: "sm", color: "gray.600", children: t("AbpUiMultiTenancy::SwitchTenantHint") })
|
|
314
491
|
] }) })
|
|
315
492
|
}
|
|
316
493
|
)
|
|
317
494
|
] });
|
|
318
495
|
}
|
|
319
496
|
function CheckIcon() {
|
|
320
|
-
return /* @__PURE__ */
|
|
497
|
+
return /* @__PURE__ */ jsx4(
|
|
321
498
|
"svg",
|
|
322
499
|
{
|
|
323
500
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -329,34 +506,27 @@ function CheckIcon() {
|
|
|
329
506
|
strokeWidth: "2",
|
|
330
507
|
strokeLinecap: "round",
|
|
331
508
|
strokeLinejoin: "round",
|
|
332
|
-
children: /* @__PURE__ */
|
|
509
|
+
children: /* @__PURE__ */ jsx4("polyline", { points: "20 6 9 17 4 12" })
|
|
333
510
|
}
|
|
334
511
|
);
|
|
335
512
|
}
|
|
336
513
|
|
|
337
514
|
// src/components/LoginForm/LoginForm.tsx
|
|
338
|
-
import { useForm } from "react-hook-form";
|
|
339
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
340
|
-
import { z } from "zod";
|
|
341
|
-
import { Link as RouterLink } from "react-router-dom";
|
|
342
|
-
import { useLocalization as useLocalization2 } from "@abpjs/core";
|
|
343
|
-
import { Alert, Button as Button2, Checkbox } from "@abpjs/theme-shared";
|
|
344
|
-
import { Box as Box2, Heading, Input as Input2, Link as Link2, HStack, Show } from "@chakra-ui/react";
|
|
345
515
|
import {
|
|
346
516
|
Card,
|
|
347
|
-
Container,
|
|
348
|
-
Field,
|
|
349
|
-
Flex,
|
|
350
|
-
InputGroup,
|
|
351
|
-
Stack,
|
|
352
|
-
Text as
|
|
517
|
+
Container as Container2,
|
|
518
|
+
Field as Field2,
|
|
519
|
+
Flex as Flex2,
|
|
520
|
+
InputGroup as InputGroup2,
|
|
521
|
+
Stack as Stack3,
|
|
522
|
+
Text as Text3
|
|
353
523
|
} from "@chakra-ui/react";
|
|
354
|
-
import { LuLock, LuMail } from "react-icons/lu";
|
|
355
|
-
import { jsx as
|
|
356
|
-
var loginSchema =
|
|
357
|
-
username:
|
|
358
|
-
password:
|
|
359
|
-
remember:
|
|
524
|
+
import { LuLock as LuLock2, LuMail } from "react-icons/lu";
|
|
525
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
526
|
+
var loginSchema = z2.object({
|
|
527
|
+
username: z2.string().min(1, "Username is required").max(255, "Username must be at most 255 characters"),
|
|
528
|
+
password: z2.string().min(1, "Password is required").max(32, "Password must be at most 32 characters"),
|
|
529
|
+
remember: z2.boolean().default(false)
|
|
360
530
|
});
|
|
361
531
|
function LoginForm({
|
|
362
532
|
showTenantBox = true,
|
|
@@ -365,14 +535,15 @@ function LoginForm({
|
|
|
365
535
|
onLoginSuccess,
|
|
366
536
|
onLoginError
|
|
367
537
|
}) {
|
|
368
|
-
const { t } =
|
|
538
|
+
const { t } = useLocalization4();
|
|
369
539
|
const { login, isLoading, error, clearError } = usePasswordFlow();
|
|
540
|
+
const isSelfRegistrationEnabled = useSelfRegistrationEnabled();
|
|
370
541
|
const {
|
|
371
542
|
register,
|
|
372
543
|
handleSubmit,
|
|
373
544
|
formState: { errors, isSubmitting }
|
|
374
|
-
} =
|
|
375
|
-
resolver:
|
|
545
|
+
} = useForm2({
|
|
546
|
+
resolver: zodResolver2(loginSchema),
|
|
376
547
|
defaultValues: {
|
|
377
548
|
username: "",
|
|
378
549
|
password: "",
|
|
@@ -391,16 +562,16 @@ function LoginForm({
|
|
|
391
562
|
}
|
|
392
563
|
};
|
|
393
564
|
const isFormLoading = isLoading || isSubmitting;
|
|
394
|
-
return /* @__PURE__ */
|
|
395
|
-
/* @__PURE__ */
|
|
396
|
-
/* @__PURE__ */
|
|
397
|
-
error && /* @__PURE__ */
|
|
398
|
-
/* @__PURE__ */
|
|
399
|
-
/* @__PURE__ */
|
|
400
|
-
/* @__PURE__ */
|
|
401
|
-
/* @__PURE__ */
|
|
402
|
-
/* @__PURE__ */
|
|
403
|
-
|
|
565
|
+
return /* @__PURE__ */ jsx5(Flex2, { height: "full", flex: "1", children: /* @__PURE__ */ jsx5(Box3, { flex: "1.5", py: { base: "24", md: "32" }, children: /* @__PURE__ */ jsx5(Container2, { maxW: "md", children: /* @__PURE__ */ jsxs4(Stack3, { gap: "8", children: [
|
|
566
|
+
/* @__PURE__ */ jsx5(Show, { when: showTenantBox, children: /* @__PURE__ */ jsx5(TenantBox, {}) }),
|
|
567
|
+
/* @__PURE__ */ jsx5(Stack3, { gap: { base: "2", md: "3" }, textAlign: "center", children: /* @__PURE__ */ jsx5(Heading, { size: { base: "2xl", md: "3xl" }, children: t("AbpAccount::Login") }) }),
|
|
568
|
+
error && /* @__PURE__ */ jsx5(Alert, { status: "error", children: error }),
|
|
569
|
+
/* @__PURE__ */ jsx5("form", { onSubmit: handleSubmit(onSubmit), noValidate: true, children: /* @__PURE__ */ jsxs4(Stack3, { gap: "6", children: [
|
|
570
|
+
/* @__PURE__ */ jsxs4(Stack3, { gap: "5", children: [
|
|
571
|
+
/* @__PURE__ */ jsxs4(Field2.Root, { invalid: !!errors.username, children: [
|
|
572
|
+
/* @__PURE__ */ jsx5(Field2.Label, { children: t("AbpAccount::UserNameOrEmailAddress") }),
|
|
573
|
+
/* @__PURE__ */ jsx5(InputGroup2, { startElement: /* @__PURE__ */ jsx5(LuMail, {}), width: "full", children: /* @__PURE__ */ jsx5(
|
|
574
|
+
Input3,
|
|
404
575
|
{
|
|
405
576
|
id: "login-input-user-name-or-email-address",
|
|
406
577
|
type: "text",
|
|
@@ -409,12 +580,12 @@ function LoginForm({
|
|
|
409
580
|
...register("username")
|
|
410
581
|
}
|
|
411
582
|
) }),
|
|
412
|
-
errors.username && /* @__PURE__ */
|
|
583
|
+
errors.username && /* @__PURE__ */ jsx5(Field2.ErrorText, { children: errors.username.message })
|
|
413
584
|
] }),
|
|
414
|
-
/* @__PURE__ */
|
|
415
|
-
/* @__PURE__ */
|
|
416
|
-
/* @__PURE__ */
|
|
417
|
-
|
|
585
|
+
/* @__PURE__ */ jsxs4(Field2.Root, { invalid: !!errors.password, children: [
|
|
586
|
+
/* @__PURE__ */ jsx5(Field2.Label, { children: t("AbpAccount::Password") }),
|
|
587
|
+
/* @__PURE__ */ jsx5(InputGroup2, { startElement: /* @__PURE__ */ jsx5(LuLock2, {}), width: "full", children: /* @__PURE__ */ jsx5(
|
|
588
|
+
Input3,
|
|
418
589
|
{
|
|
419
590
|
id: "login-input-password",
|
|
420
591
|
type: "password",
|
|
@@ -423,11 +594,11 @@ function LoginForm({
|
|
|
423
594
|
...register("password")
|
|
424
595
|
}
|
|
425
596
|
) }),
|
|
426
|
-
errors.password && /* @__PURE__ */
|
|
597
|
+
errors.password && /* @__PURE__ */ jsx5(Field2.ErrorText, { children: errors.password.message })
|
|
427
598
|
] }),
|
|
428
|
-
/* @__PURE__ */
|
|
429
|
-
/* @__PURE__ */
|
|
430
|
-
|
|
599
|
+
/* @__PURE__ */ jsx5(Checkbox, { id: "login-input-remember-me", ...register("remember"), children: t("AbpAccount::RememberMe") }),
|
|
600
|
+
/* @__PURE__ */ jsx5(
|
|
601
|
+
Button3,
|
|
431
602
|
{
|
|
432
603
|
type: "submit",
|
|
433
604
|
colorPalette: "blue",
|
|
@@ -436,56 +607,265 @@ function LoginForm({
|
|
|
436
607
|
children: t("AbpAccount::Login")
|
|
437
608
|
}
|
|
438
609
|
),
|
|
439
|
-
/* @__PURE__ */
|
|
610
|
+
/* @__PURE__ */ jsx5(Link2, { variant: "plain", children: t("AbpAccount::ForgotPassword") })
|
|
440
611
|
] }),
|
|
441
|
-
/* @__PURE__ */
|
|
442
|
-
/* @__PURE__ */
|
|
443
|
-
/* @__PURE__ */
|
|
612
|
+
/* @__PURE__ */ jsx5(Show, { when: showRegisterLink && isSelfRegistrationEnabled, children: /* @__PURE__ */ jsx5(Card.Root, { size: "sm", mt: "10", children: /* @__PURE__ */ jsx5(Card.Body, { children: /* @__PURE__ */ jsxs4(HStack, { textStyle: "sm", children: [
|
|
613
|
+
/* @__PURE__ */ jsx5(Text3, { children: t("AbpAccount::AreYouANewUser") }),
|
|
614
|
+
/* @__PURE__ */ jsx5(Link2, { asChild: true, variant: "underline", fontWeight: "semibold", children: /* @__PURE__ */ jsx5(RouterLink, { to: registerUrl, children: t("AbpAccount::Register") }) })
|
|
444
615
|
] }) }) }) })
|
|
445
616
|
] }) })
|
|
446
617
|
] }) }) }) });
|
|
447
618
|
}
|
|
448
619
|
|
|
620
|
+
// src/components/ManageProfile/ManageProfile.tsx
|
|
621
|
+
import { useState as useState5 } from "react";
|
|
622
|
+
import { useLocalization as useLocalization6 } from "@abpjs/core";
|
|
623
|
+
import { Box as Box4, Container as Container3, Heading as Heading2, Stack as Stack5, Tabs } from "@chakra-ui/react";
|
|
624
|
+
|
|
625
|
+
// src/components/PersonalSettingsForm/PersonalSettingsForm.tsx
|
|
626
|
+
import { useState as useState4, useEffect as useEffect3 } from "react";
|
|
627
|
+
import { useForm as useForm3 } from "react-hook-form";
|
|
628
|
+
import { zodResolver as zodResolver3 } from "@hookform/resolvers/zod";
|
|
629
|
+
import { z as z3 } from "zod";
|
|
630
|
+
import { useLocalization as useLocalization5, useProfile as useProfile2 } from "@abpjs/core";
|
|
631
|
+
import { Button as Button4, useToaster as useToaster3 } from "@abpjs/theme-shared";
|
|
632
|
+
import { Input as Input4, Stack as Stack4 } from "@chakra-ui/react";
|
|
633
|
+
import { Field as Field3, InputGroup as InputGroup3 } from "@chakra-ui/react";
|
|
634
|
+
import { LuMail as LuMail2, LuUser, LuPhone } from "react-icons/lu";
|
|
635
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
636
|
+
var personalSettingsSchema = z3.object({
|
|
637
|
+
userName: z3.string().min(1, "Username is required").max(255, "Username must be at most 255 characters"),
|
|
638
|
+
email: z3.string().min(1, "Email is required").email("Please enter a valid email address"),
|
|
639
|
+
name: z3.string().max(64, "Name must be at most 64 characters").optional(),
|
|
640
|
+
surname: z3.string().max(64, "Surname must be at most 64 characters").optional(),
|
|
641
|
+
phoneNumber: z3.string().max(16, "Phone number must be at most 16 characters").optional()
|
|
642
|
+
});
|
|
643
|
+
function PersonalSettingsForm({ onSuccess, onError }) {
|
|
644
|
+
const { t } = useLocalization5();
|
|
645
|
+
const { profile, loading, fetchProfile, updateProfile } = useProfile2();
|
|
646
|
+
const toaster = useToaster3();
|
|
647
|
+
const [inProgress, setInProgress] = useState4(false);
|
|
648
|
+
const {
|
|
649
|
+
register,
|
|
650
|
+
handleSubmit,
|
|
651
|
+
reset,
|
|
652
|
+
formState: { errors }
|
|
653
|
+
} = useForm3({
|
|
654
|
+
resolver: zodResolver3(personalSettingsSchema),
|
|
655
|
+
defaultValues: {
|
|
656
|
+
userName: "",
|
|
657
|
+
email: "",
|
|
658
|
+
name: "",
|
|
659
|
+
surname: "",
|
|
660
|
+
phoneNumber: ""
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
useEffect3(() => {
|
|
664
|
+
fetchProfile();
|
|
665
|
+
}, [fetchProfile]);
|
|
666
|
+
useEffect3(() => {
|
|
667
|
+
if (profile) {
|
|
668
|
+
reset({
|
|
669
|
+
userName: profile.userName || "",
|
|
670
|
+
email: profile.email || "",
|
|
671
|
+
name: profile.name || "",
|
|
672
|
+
surname: profile.surname || "",
|
|
673
|
+
phoneNumber: profile.phoneNumber || ""
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
}, [profile, reset]);
|
|
677
|
+
const submit = async (data) => {
|
|
678
|
+
setInProgress(true);
|
|
679
|
+
try {
|
|
680
|
+
const updateData = {
|
|
681
|
+
userName: data.userName,
|
|
682
|
+
email: data.email,
|
|
683
|
+
name: data.name || "",
|
|
684
|
+
surname: data.surname || "",
|
|
685
|
+
phoneNumber: data.phoneNumber || ""
|
|
686
|
+
};
|
|
687
|
+
await updateProfile(updateData);
|
|
688
|
+
toaster.success(
|
|
689
|
+
t("AbpAccount::PersonalSettingsSaved") || "Personal settings have been saved successfully.",
|
|
690
|
+
t("AbpAccount::Success") || "Success"
|
|
691
|
+
);
|
|
692
|
+
onSuccess?.();
|
|
693
|
+
} catch (err) {
|
|
694
|
+
const errorMessage = err?.error?.error_description || err?.error?.error?.message || t("AbpAccount::DefaultErrorMessage") || "An error occurred";
|
|
695
|
+
toaster.error(errorMessage, t("AbpUi::Error") || "Error", { life: 7e3 });
|
|
696
|
+
onError?.(errorMessage);
|
|
697
|
+
} finally {
|
|
698
|
+
setInProgress(false);
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
if (loading && !profile) {
|
|
702
|
+
return null;
|
|
703
|
+
}
|
|
704
|
+
return /* @__PURE__ */ jsx6("form", { onSubmit: handleSubmit(submit), noValidate: true, children: /* @__PURE__ */ jsxs5(Stack4, { gap: "5", children: [
|
|
705
|
+
/* @__PURE__ */ jsxs5(Field3.Root, { invalid: !!errors.userName, children: [
|
|
706
|
+
/* @__PURE__ */ jsx6(Field3.Label, { children: t("AbpAccount::UserName") }),
|
|
707
|
+
/* @__PURE__ */ jsx6(InputGroup3, { startElement: /* @__PURE__ */ jsx6(LuUser, {}), width: "full", children: /* @__PURE__ */ jsx6(
|
|
708
|
+
Input4,
|
|
709
|
+
{
|
|
710
|
+
id: "user-name",
|
|
711
|
+
type: "text",
|
|
712
|
+
autoComplete: "username",
|
|
713
|
+
...register("userName")
|
|
714
|
+
}
|
|
715
|
+
) }),
|
|
716
|
+
errors.userName && /* @__PURE__ */ jsx6(Field3.ErrorText, { children: errors.userName.message })
|
|
717
|
+
] }),
|
|
718
|
+
/* @__PURE__ */ jsxs5(Field3.Root, { invalid: !!errors.email, children: [
|
|
719
|
+
/* @__PURE__ */ jsx6(Field3.Label, { children: t("AbpAccount::EmailAddress") }),
|
|
720
|
+
/* @__PURE__ */ jsx6(InputGroup3, { startElement: /* @__PURE__ */ jsx6(LuMail2, {}), width: "full", children: /* @__PURE__ */ jsx6(
|
|
721
|
+
Input4,
|
|
722
|
+
{
|
|
723
|
+
id: "email",
|
|
724
|
+
type: "email",
|
|
725
|
+
autoComplete: "email",
|
|
726
|
+
...register("email")
|
|
727
|
+
}
|
|
728
|
+
) }),
|
|
729
|
+
errors.email && /* @__PURE__ */ jsx6(Field3.ErrorText, { children: errors.email.message })
|
|
730
|
+
] }),
|
|
731
|
+
/* @__PURE__ */ jsxs5(Field3.Root, { invalid: !!errors.name, children: [
|
|
732
|
+
/* @__PURE__ */ jsx6(Field3.Label, { children: t("AbpAccount::DisplayName:Name") }),
|
|
733
|
+
/* @__PURE__ */ jsx6(InputGroup3, { startElement: /* @__PURE__ */ jsx6(LuUser, {}), width: "full", children: /* @__PURE__ */ jsx6(
|
|
734
|
+
Input4,
|
|
735
|
+
{
|
|
736
|
+
id: "name",
|
|
737
|
+
type: "text",
|
|
738
|
+
autoComplete: "given-name",
|
|
739
|
+
...register("name")
|
|
740
|
+
}
|
|
741
|
+
) }),
|
|
742
|
+
errors.name && /* @__PURE__ */ jsx6(Field3.ErrorText, { children: errors.name.message })
|
|
743
|
+
] }),
|
|
744
|
+
/* @__PURE__ */ jsxs5(Field3.Root, { invalid: !!errors.surname, children: [
|
|
745
|
+
/* @__PURE__ */ jsx6(Field3.Label, { children: t("AbpAccount::DisplayName:Surname") }),
|
|
746
|
+
/* @__PURE__ */ jsx6(InputGroup3, { startElement: /* @__PURE__ */ jsx6(LuUser, {}), width: "full", children: /* @__PURE__ */ jsx6(
|
|
747
|
+
Input4,
|
|
748
|
+
{
|
|
749
|
+
id: "surname",
|
|
750
|
+
type: "text",
|
|
751
|
+
autoComplete: "family-name",
|
|
752
|
+
...register("surname")
|
|
753
|
+
}
|
|
754
|
+
) }),
|
|
755
|
+
errors.surname && /* @__PURE__ */ jsx6(Field3.ErrorText, { children: errors.surname.message })
|
|
756
|
+
] }),
|
|
757
|
+
/* @__PURE__ */ jsxs5(Field3.Root, { invalid: !!errors.phoneNumber, children: [
|
|
758
|
+
/* @__PURE__ */ jsx6(Field3.Label, { children: t("AbpAccount::PhoneNumber") }),
|
|
759
|
+
/* @__PURE__ */ jsx6(InputGroup3, { startElement: /* @__PURE__ */ jsx6(LuPhone, {}), width: "full", children: /* @__PURE__ */ jsx6(
|
|
760
|
+
Input4,
|
|
761
|
+
{
|
|
762
|
+
id: "phone-number",
|
|
763
|
+
type: "tel",
|
|
764
|
+
autoComplete: "tel",
|
|
765
|
+
...register("phoneNumber")
|
|
766
|
+
}
|
|
767
|
+
) }),
|
|
768
|
+
errors.phoneNumber && /* @__PURE__ */ jsx6(Field3.ErrorText, { children: errors.phoneNumber.message })
|
|
769
|
+
] }),
|
|
770
|
+
/* @__PURE__ */ jsx6(
|
|
771
|
+
Button4,
|
|
772
|
+
{
|
|
773
|
+
type: "submit",
|
|
774
|
+
colorPalette: "blue",
|
|
775
|
+
loading: inProgress,
|
|
776
|
+
loadingText: t("AbpAccount::Submit"),
|
|
777
|
+
children: t("AbpAccount::Submit")
|
|
778
|
+
}
|
|
779
|
+
)
|
|
780
|
+
] }) });
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// src/components/ManageProfile/ManageProfile.tsx
|
|
784
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
785
|
+
function ManageProfile({
|
|
786
|
+
defaultTabIndex = 0,
|
|
787
|
+
onTabChange,
|
|
788
|
+
customTabs
|
|
789
|
+
}) {
|
|
790
|
+
const { t } = useLocalization6();
|
|
791
|
+
const [selectedTab, setSelectedTab] = useState5(defaultTabIndex);
|
|
792
|
+
const defaultTabs = [
|
|
793
|
+
{
|
|
794
|
+
id: "personal-settings",
|
|
795
|
+
label: t("AbpAccount::PersonalSettings") || "Personal Settings",
|
|
796
|
+
content: /* @__PURE__ */ jsx7(PersonalSettingsForm, {})
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
id: "change-password",
|
|
800
|
+
label: t("AbpAccount::ChangePassword") || "Change Password",
|
|
801
|
+
content: /* @__PURE__ */ jsx7(ChangePasswordForm, {})
|
|
802
|
+
}
|
|
803
|
+
];
|
|
804
|
+
const tabs = customTabs || defaultTabs;
|
|
805
|
+
const handleTabChange = (details) => {
|
|
806
|
+
const index = tabs.findIndex((tab) => tab.id === details.value);
|
|
807
|
+
if (index !== -1) {
|
|
808
|
+
setSelectedTab(index);
|
|
809
|
+
onTabChange?.(index);
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
return /* @__PURE__ */ jsx7(Box4, { className: "manage-profile", py: { base: "8", md: "12" }, children: /* @__PURE__ */ jsx7(Container3, { maxW: "2xl", children: /* @__PURE__ */ jsxs6(Stack5, { gap: "8", children: [
|
|
813
|
+
/* @__PURE__ */ jsx7(Heading2, { size: "xl", children: t("AbpAccount::ManageYourAccount") || "Manage Your Account" }),
|
|
814
|
+
/* @__PURE__ */ jsxs6(
|
|
815
|
+
Tabs.Root,
|
|
816
|
+
{
|
|
817
|
+
value: tabs[selectedTab]?.id,
|
|
818
|
+
onValueChange: handleTabChange,
|
|
819
|
+
variant: "enclosed",
|
|
820
|
+
children: [
|
|
821
|
+
/* @__PURE__ */ jsx7(Tabs.List, { children: tabs.map((tab) => /* @__PURE__ */ jsx7(Tabs.Trigger, { value: tab.id, children: tab.label }, tab.id)) }),
|
|
822
|
+
tabs.map((tab) => /* @__PURE__ */ jsx7(Tabs.Content, { value: tab.id, children: /* @__PURE__ */ jsx7(Box4, { pt: 6, children: tab.content }) }, tab.id))
|
|
823
|
+
]
|
|
824
|
+
}
|
|
825
|
+
)
|
|
826
|
+
] }) }) });
|
|
827
|
+
}
|
|
828
|
+
|
|
449
829
|
// src/components/RegisterForm/RegisterForm.tsx
|
|
450
|
-
import { useState as
|
|
451
|
-
import { useForm as
|
|
452
|
-
import { zodResolver as
|
|
453
|
-
import { z as
|
|
830
|
+
import { useState as useState6, useEffect as useEffect4 } from "react";
|
|
831
|
+
import { useForm as useForm4 } from "react-hook-form";
|
|
832
|
+
import { zodResolver as zodResolver4 } from "@hookform/resolvers/zod";
|
|
833
|
+
import { z as z4 } from "zod";
|
|
454
834
|
import { Link as RouterLink2, useNavigate as useNavigate2 } from "react-router-dom";
|
|
455
|
-
import { useLocalization as
|
|
456
|
-
import { Button as
|
|
457
|
-
import { Box as
|
|
835
|
+
import { useLocalization as useLocalization7, useUserManager, useAbp as useAbp2, configActions as configActions2 } from "@abpjs/core";
|
|
836
|
+
import { Button as Button5, useToaster as useToaster4 } from "@abpjs/theme-shared";
|
|
837
|
+
import { Box as Box5, Heading as Heading3, Input as Input5, Link as Link3, HStack as HStack2, Show as Show2 } from "@chakra-ui/react";
|
|
458
838
|
import {
|
|
459
839
|
Card as Card2,
|
|
460
|
-
Container as
|
|
461
|
-
Field as
|
|
462
|
-
Flex as
|
|
463
|
-
InputGroup as
|
|
464
|
-
Stack as
|
|
465
|
-
Text as
|
|
840
|
+
Container as Container4,
|
|
841
|
+
Field as Field4,
|
|
842
|
+
Flex as Flex3,
|
|
843
|
+
InputGroup as InputGroup4,
|
|
844
|
+
Stack as Stack6,
|
|
845
|
+
Text as Text4
|
|
466
846
|
} from "@chakra-ui/react";
|
|
467
|
-
import { LuLock as
|
|
468
|
-
import { jsx as
|
|
469
|
-
var
|
|
847
|
+
import { LuLock as LuLock3, LuMail as LuMail3, LuUser as LuUser2 } from "react-icons/lu";
|
|
848
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
849
|
+
var passwordValidation2 = {
|
|
470
850
|
hasLowercase: /[a-z]/,
|
|
471
851
|
hasUppercase: /[A-Z]/,
|
|
472
852
|
hasNumber: /[0-9]/,
|
|
473
853
|
hasSpecial: /[!@#$%^&*(),.?":{}|<>]/
|
|
474
854
|
};
|
|
475
|
-
var registerSchema =
|
|
476
|
-
username:
|
|
477
|
-
email:
|
|
478
|
-
password:
|
|
479
|
-
(val) =>
|
|
855
|
+
var registerSchema = z4.object({
|
|
856
|
+
username: z4.string().min(1, "Username is required").max(255, "Username must be at most 255 characters"),
|
|
857
|
+
email: z4.string().min(1, "Email is required").email("Please enter a valid email address"),
|
|
858
|
+
password: z4.string().min(6, "Password must be at least 6 characters").max(32, "Password must be at most 32 characters").refine(
|
|
859
|
+
(val) => passwordValidation2.hasLowercase.test(val),
|
|
480
860
|
"Password must contain at least one lowercase letter"
|
|
481
861
|
).refine(
|
|
482
|
-
(val) =>
|
|
862
|
+
(val) => passwordValidation2.hasUppercase.test(val),
|
|
483
863
|
"Password must contain at least one uppercase letter"
|
|
484
864
|
).refine(
|
|
485
|
-
(val) =>
|
|
865
|
+
(val) => passwordValidation2.hasNumber.test(val),
|
|
486
866
|
"Password must contain at least one number"
|
|
487
867
|
).refine(
|
|
488
|
-
(val) =>
|
|
868
|
+
(val) => passwordValidation2.hasSpecial.test(val),
|
|
489
869
|
"Password must contain at least one special character"
|
|
490
870
|
)
|
|
491
871
|
});
|
|
@@ -496,19 +876,25 @@ function RegisterForm({
|
|
|
496
876
|
onRegisterSuccess,
|
|
497
877
|
onRegisterError
|
|
498
878
|
}) {
|
|
499
|
-
const { t } =
|
|
879
|
+
const { t } = useLocalization7();
|
|
500
880
|
const navigate = useNavigate2();
|
|
501
881
|
const accountService = useAccountService();
|
|
502
|
-
const toaster =
|
|
882
|
+
const toaster = useToaster4();
|
|
503
883
|
const userManager = useUserManager();
|
|
504
884
|
const { store, applicationConfigurationService } = useAbp2();
|
|
505
|
-
const [inProgress, setInProgress] =
|
|
885
|
+
const [inProgress, setInProgress] = useState6(false);
|
|
886
|
+
const isSelfRegistrationEnabled = useSelfRegistrationEnabled();
|
|
887
|
+
useEffect4(() => {
|
|
888
|
+
if (!isSelfRegistrationEnabled) {
|
|
889
|
+
navigate(loginUrl, { replace: true });
|
|
890
|
+
}
|
|
891
|
+
}, [isSelfRegistrationEnabled, navigate, loginUrl]);
|
|
506
892
|
const {
|
|
507
893
|
register,
|
|
508
894
|
handleSubmit,
|
|
509
895
|
formState: { errors }
|
|
510
|
-
} =
|
|
511
|
-
resolver:
|
|
896
|
+
} = useForm4({
|
|
897
|
+
resolver: zodResolver4(registerSchema),
|
|
512
898
|
defaultValues: {
|
|
513
899
|
username: "",
|
|
514
900
|
email: "",
|
|
@@ -560,15 +946,15 @@ function RegisterForm({
|
|
|
560
946
|
setInProgress(false);
|
|
561
947
|
}
|
|
562
948
|
};
|
|
563
|
-
return /* @__PURE__ */
|
|
564
|
-
/* @__PURE__ */
|
|
565
|
-
/* @__PURE__ */
|
|
566
|
-
/* @__PURE__ */
|
|
567
|
-
/* @__PURE__ */
|
|
568
|
-
/* @__PURE__ */
|
|
569
|
-
/* @__PURE__ */
|
|
570
|
-
/* @__PURE__ */
|
|
571
|
-
|
|
949
|
+
return /* @__PURE__ */ jsx8(Flex3, { height: "full", flex: "1", children: /* @__PURE__ */ jsx8(Box5, { flex: "1.5", py: { base: "24", md: "32" }, children: /* @__PURE__ */ jsx8(Container4, { maxW: "md", children: /* @__PURE__ */ jsxs7(Stack6, { gap: "8", children: [
|
|
950
|
+
/* @__PURE__ */ jsx8(Show2, { when: showTenantBox, children: /* @__PURE__ */ jsx8(TenantBox, {}) }),
|
|
951
|
+
/* @__PURE__ */ jsx8(Stack6, { gap: { base: "2", md: "3" }, textAlign: "center", children: /* @__PURE__ */ jsx8(Heading3, { size: { base: "2xl", md: "3xl" }, children: t("AbpAccount::Register") }) }),
|
|
952
|
+
/* @__PURE__ */ jsx8("form", { onSubmit: handleSubmit(onSubmit), noValidate: true, children: /* @__PURE__ */ jsxs7(Stack6, { gap: "6", children: [
|
|
953
|
+
/* @__PURE__ */ jsxs7(Stack6, { gap: "5", children: [
|
|
954
|
+
/* @__PURE__ */ jsxs7(Field4.Root, { invalid: !!errors.username, children: [
|
|
955
|
+
/* @__PURE__ */ jsx8(Field4.Label, { children: t("AbpAccount::UserName") }),
|
|
956
|
+
/* @__PURE__ */ jsx8(InputGroup4, { startElement: /* @__PURE__ */ jsx8(LuUser2, {}), width: "full", children: /* @__PURE__ */ jsx8(
|
|
957
|
+
Input5,
|
|
572
958
|
{
|
|
573
959
|
id: "input-user-name",
|
|
574
960
|
type: "text",
|
|
@@ -578,12 +964,12 @@ function RegisterForm({
|
|
|
578
964
|
...register("username")
|
|
579
965
|
}
|
|
580
966
|
) }),
|
|
581
|
-
errors.username && /* @__PURE__ */
|
|
967
|
+
errors.username && /* @__PURE__ */ jsx8(Field4.ErrorText, { children: errors.username.message })
|
|
582
968
|
] }),
|
|
583
|
-
/* @__PURE__ */
|
|
584
|
-
/* @__PURE__ */
|
|
585
|
-
/* @__PURE__ */
|
|
586
|
-
|
|
969
|
+
/* @__PURE__ */ jsxs7(Field4.Root, { invalid: !!errors.email, children: [
|
|
970
|
+
/* @__PURE__ */ jsx8(Field4.Label, { children: t("AbpAccount::EmailAddress") }),
|
|
971
|
+
/* @__PURE__ */ jsx8(InputGroup4, { startElement: /* @__PURE__ */ jsx8(LuMail3, {}), width: "full", children: /* @__PURE__ */ jsx8(
|
|
972
|
+
Input5,
|
|
587
973
|
{
|
|
588
974
|
id: "input-email-address",
|
|
589
975
|
type: "email",
|
|
@@ -592,12 +978,12 @@ function RegisterForm({
|
|
|
592
978
|
...register("email")
|
|
593
979
|
}
|
|
594
980
|
) }),
|
|
595
|
-
errors.email && /* @__PURE__ */
|
|
981
|
+
errors.email && /* @__PURE__ */ jsx8(Field4.ErrorText, { children: errors.email.message })
|
|
596
982
|
] }),
|
|
597
|
-
/* @__PURE__ */
|
|
598
|
-
/* @__PURE__ */
|
|
599
|
-
/* @__PURE__ */
|
|
600
|
-
|
|
983
|
+
/* @__PURE__ */ jsxs7(Field4.Root, { invalid: !!errors.password, children: [
|
|
984
|
+
/* @__PURE__ */ jsx8(Field4.Label, { children: t("AbpAccount::Password") }),
|
|
985
|
+
/* @__PURE__ */ jsx8(InputGroup4, { startElement: /* @__PURE__ */ jsx8(LuLock3, {}), width: "full", children: /* @__PURE__ */ jsx8(
|
|
986
|
+
Input5,
|
|
601
987
|
{
|
|
602
988
|
id: "input-password",
|
|
603
989
|
type: "password",
|
|
@@ -606,10 +992,10 @@ function RegisterForm({
|
|
|
606
992
|
...register("password")
|
|
607
993
|
}
|
|
608
994
|
) }),
|
|
609
|
-
errors.password && /* @__PURE__ */
|
|
995
|
+
errors.password && /* @__PURE__ */ jsx8(Field4.ErrorText, { children: errors.password.message })
|
|
610
996
|
] }),
|
|
611
|
-
/* @__PURE__ */
|
|
612
|
-
|
|
997
|
+
/* @__PURE__ */ jsx8(
|
|
998
|
+
Button5,
|
|
613
999
|
{
|
|
614
1000
|
type: "submit",
|
|
615
1001
|
colorPalette: "blue",
|
|
@@ -619,58 +1005,35 @@ function RegisterForm({
|
|
|
619
1005
|
}
|
|
620
1006
|
)
|
|
621
1007
|
] }),
|
|
622
|
-
/* @__PURE__ */
|
|
623
|
-
/* @__PURE__ */
|
|
624
|
-
/* @__PURE__ */
|
|
1008
|
+
/* @__PURE__ */ jsx8(Show2, { when: showLoginLink, children: /* @__PURE__ */ jsx8(Card2.Root, { size: "sm", mt: "10", children: /* @__PURE__ */ jsx8(Card2.Body, { children: /* @__PURE__ */ jsxs7(HStack2, { textStyle: "sm", children: [
|
|
1009
|
+
/* @__PURE__ */ jsx8(Text4, { children: t("AbpAccount::AlreadyRegistered") }),
|
|
1010
|
+
/* @__PURE__ */ jsx8(Link3, { asChild: true, variant: "underline", fontWeight: "semibold", children: /* @__PURE__ */ jsx8(RouterLink2, { to: loginUrl, children: t("AbpAccount::Login") }) })
|
|
625
1011
|
] }) }) }) })
|
|
626
1012
|
] }) })
|
|
627
1013
|
] }) }) }) });
|
|
628
1014
|
}
|
|
629
1015
|
|
|
630
1016
|
// src/pages/LoginPage.tsx
|
|
631
|
-
import { Container as
|
|
632
|
-
import { jsx as
|
|
1017
|
+
import { Container as Container5, Center } from "@chakra-ui/react";
|
|
1018
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
633
1019
|
function LoginPage({
|
|
634
1020
|
maxWidth = "container.sm",
|
|
635
1021
|
...loginFormProps
|
|
636
1022
|
}) {
|
|
637
|
-
return /* @__PURE__ */
|
|
1023
|
+
return /* @__PURE__ */ jsx9(Container5, { maxW: maxWidth, py: 10, children: /* @__PURE__ */ jsx9(Center, { children: /* @__PURE__ */ jsx9(LoginForm, { ...loginFormProps }) }) });
|
|
638
1024
|
}
|
|
639
1025
|
|
|
640
1026
|
// src/pages/RegisterPage.tsx
|
|
641
|
-
import { Container as
|
|
642
|
-
import { jsx as
|
|
1027
|
+
import { Container as Container6, Center as Center2 } from "@chakra-ui/react";
|
|
1028
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
643
1029
|
function RegisterPage({
|
|
644
1030
|
maxWidth = "container.sm",
|
|
645
1031
|
...registerFormProps
|
|
646
1032
|
}) {
|
|
647
|
-
return /* @__PURE__ */
|
|
1033
|
+
return /* @__PURE__ */ jsx10(Container6, { maxW: maxWidth, py: 10, children: /* @__PURE__ */ jsx10(Center2, { children: /* @__PURE__ */ jsx10(RegisterForm, { ...registerFormProps }) }) });
|
|
648
1034
|
}
|
|
649
1035
|
|
|
650
1036
|
// src/routes/index.ts
|
|
651
|
-
import { eLayoutType } from "@abpjs/core";
|
|
652
|
-
var ACCOUNT_ROUTES = {
|
|
653
|
-
routes: [
|
|
654
|
-
{
|
|
655
|
-
name: "Account",
|
|
656
|
-
path: "account",
|
|
657
|
-
invisible: true,
|
|
658
|
-
layout: eLayoutType.application,
|
|
659
|
-
children: [
|
|
660
|
-
{
|
|
661
|
-
path: "login",
|
|
662
|
-
name: "Login",
|
|
663
|
-
order: 1
|
|
664
|
-
},
|
|
665
|
-
{
|
|
666
|
-
path: "register",
|
|
667
|
-
name: "Register",
|
|
668
|
-
order: 2
|
|
669
|
-
}
|
|
670
|
-
]
|
|
671
|
-
}
|
|
672
|
-
]
|
|
673
|
-
};
|
|
674
1037
|
var DEFAULT_REDIRECT_URL = "/";
|
|
675
1038
|
var ACCOUNT_PATHS = {
|
|
676
1039
|
login: "/account/login",
|
|
@@ -678,17 +1041,21 @@ var ACCOUNT_PATHS = {
|
|
|
678
1041
|
};
|
|
679
1042
|
export {
|
|
680
1043
|
ACCOUNT_PATHS,
|
|
681
|
-
ACCOUNT_ROUTES,
|
|
682
1044
|
AccountProvider,
|
|
683
1045
|
AccountService,
|
|
1046
|
+
AuthWrapper,
|
|
1047
|
+
ChangePasswordForm,
|
|
684
1048
|
DEFAULT_REDIRECT_URL,
|
|
685
1049
|
LoginForm,
|
|
686
1050
|
LoginPage,
|
|
1051
|
+
ManageProfile,
|
|
1052
|
+
PersonalSettingsForm,
|
|
687
1053
|
RegisterForm,
|
|
688
1054
|
RegisterPage,
|
|
689
1055
|
TenantBox,
|
|
690
1056
|
useAccountContext,
|
|
691
1057
|
useAccountOptions,
|
|
692
1058
|
useAccountService,
|
|
693
|
-
usePasswordFlow
|
|
1059
|
+
usePasswordFlow,
|
|
1060
|
+
useSelfRegistrationEnabled
|
|
694
1061
|
};
|