@open-mercato/core 0.5.1-develop.2851.2854b4507f → 0.5.1-develop.2856.35de414092
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.
|
@@ -20,9 +20,23 @@ function ResetWithTokenPage({ params }) {
|
|
|
20
20
|
async function onSubmit(e) {
|
|
21
21
|
e.preventDefault();
|
|
22
22
|
setError(null);
|
|
23
|
+
const form = new FormData(e.currentTarget);
|
|
24
|
+
const password = String(form.get("password") ?? "");
|
|
25
|
+
const confirmPassword = String(form.get("confirmPassword") ?? "");
|
|
26
|
+
if (!password) {
|
|
27
|
+
setError(t("auth.profile.form.errors.newPasswordRequired", "New password is required."));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (!confirmPassword) {
|
|
31
|
+
setError(t("auth.profile.form.errors.confirmPasswordRequired", "Please confirm the new password."));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (password !== confirmPassword) {
|
|
35
|
+
setError(t("auth.profile.form.errors.passwordMismatch", "Passwords do not match."));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
23
38
|
setSubmitting(true);
|
|
24
39
|
try {
|
|
25
|
-
const form = new FormData(e.currentTarget);
|
|
26
40
|
form.set("token", params.token);
|
|
27
41
|
const { ok, result } = await apiCall(
|
|
28
42
|
"/api/auth/reset/confirm",
|
|
@@ -43,12 +57,25 @@ function ResetWithTokenPage({ params }) {
|
|
|
43
57
|
/* @__PURE__ */ jsx(CardDescription, { children: t("auth.reset.subtitle", "Choose a strong password for your account.") })
|
|
44
58
|
] }),
|
|
45
59
|
/* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs("form", { className: "grid gap-3", onSubmit, children: [
|
|
46
|
-
error && /* @__PURE__ */ jsx("div", { className: "text-sm text-
|
|
60
|
+
error && /* @__PURE__ */ jsx("div", { className: "text-sm text-status-error-text", children: error }),
|
|
47
61
|
/* @__PURE__ */ jsxs("div", { className: "grid gap-1", children: [
|
|
48
62
|
/* @__PURE__ */ jsx(Label, { htmlFor: "password", children: t("auth.reset.form.password", "New password") }),
|
|
49
63
|
/* @__PURE__ */ jsx(Input, { id: "password", name: "password", type: "password", required: true, minLength: passwordPolicy.minLength }),
|
|
50
64
|
passwordDescription ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: passwordDescription }) : null
|
|
51
65
|
] }),
|
|
66
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-1", children: [
|
|
67
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "confirmPassword", children: t("auth.profile.form.confirmPassword", "Confirm new password") }),
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
Input,
|
|
70
|
+
{
|
|
71
|
+
id: "confirmPassword",
|
|
72
|
+
name: "confirmPassword",
|
|
73
|
+
type: "password",
|
|
74
|
+
required: true,
|
|
75
|
+
minLength: passwordPolicy.minLength
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
] }),
|
|
52
79
|
/* @__PURE__ */ jsx(Button, { type: "submit", className: "mt-2 w-full", disabled: submitting, children: submitting ? t("auth.reset.form.loading", "...") : t("auth.reset.form.submit", "Update password") })
|
|
53
80
|
] }) })
|
|
54
81
|
] }) });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/modules/auth/frontend/reset/%5Btoken%5D/page.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\nimport { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@open-mercato/ui/primitives/card'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Label } from '@open-mercato/ui/primitives/label'\nimport { useState } from 'react'\nimport { useRouter } from 'next/navigation'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { formatPasswordRequirements, getPasswordPolicy } from '@open-mercato/shared/lib/auth/passwordPolicy'\n\nexport default function ResetWithTokenPage({ params }: { params: { token: string } }) {\n const router = useRouter()\n const t = useT()\n const [error, setError] = useState<string | null>(null)\n const [submitting, setSubmitting] = useState(false)\n const passwordPolicy = getPasswordPolicy()\n const passwordRequirements = formatPasswordRequirements(passwordPolicy, t)\n const passwordDescription = passwordRequirements\n ? t('auth.password.requirements.help', 'Password requirements: {requirements}', { requirements: passwordRequirements })\n : ''\n\n async function onSubmit(e: React.FormEvent<HTMLFormElement>) {\n e.preventDefault()\n setError(null)\n
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@open-mercato/ui/primitives/card'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Label } from '@open-mercato/ui/primitives/label'\nimport { useState } from 'react'\nimport { useRouter } from 'next/navigation'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { formatPasswordRequirements, getPasswordPolicy } from '@open-mercato/shared/lib/auth/passwordPolicy'\n\nexport default function ResetWithTokenPage({ params }: { params: { token: string } }) {\n const router = useRouter()\n const t = useT()\n const [error, setError] = useState<string | null>(null)\n const [submitting, setSubmitting] = useState(false)\n const passwordPolicy = getPasswordPolicy()\n const passwordRequirements = formatPasswordRequirements(passwordPolicy, t)\n const passwordDescription = passwordRequirements\n ? t('auth.password.requirements.help', 'Password requirements: {requirements}', { requirements: passwordRequirements })\n : ''\n\n async function onSubmit(e: React.FormEvent<HTMLFormElement>) {\n e.preventDefault()\n setError(null)\n const form = new FormData(e.currentTarget)\n const password = String(form.get('password') ?? '')\n const confirmPassword = String(form.get('confirmPassword') ?? '')\n\n if (!password) {\n setError(t('auth.profile.form.errors.newPasswordRequired', 'New password is required.'))\n return\n }\n if (!confirmPassword) {\n setError(t('auth.profile.form.errors.confirmPasswordRequired', 'Please confirm the new password.'))\n return\n }\n if (password !== confirmPassword) {\n setError(t('auth.profile.form.errors.passwordMismatch', 'Passwords do not match.'))\n return\n }\n\n setSubmitting(true)\n try {\n form.set('token', params.token)\n const { ok, result } = await apiCall<{ ok?: boolean; error?: string; redirect?: string }>(\n '/api/auth/reset/confirm',\n { method: 'POST', body: form },\n )\n if (!ok || result?.ok === false) {\n setError(result?.error || t('auth.reset.errors.failed', 'Unable to reset password'))\n return\n }\n router.replace(result?.redirect || '/login')\n } finally {\n setSubmitting(false)\n }\n }\n\n return (\n <div className=\"min-h-svh flex items-center justify-center p-4\">\n <Card className=\"w-full max-w-sm\">\n <CardHeader>\n <CardTitle>{t('auth.reset.title', 'Set a new password')}</CardTitle>\n <CardDescription>{t('auth.reset.subtitle', 'Choose a strong password for your account.')}</CardDescription>\n </CardHeader>\n <CardContent>\n <form className=\"grid gap-3\" onSubmit={onSubmit}>\n {error && <div className=\"text-sm text-status-error-text\">{error}</div>}\n <div className=\"grid gap-1\">\n <Label htmlFor=\"password\">{t('auth.reset.form.password', 'New password')}</Label>\n <Input id=\"password\" name=\"password\" type=\"password\" required minLength={passwordPolicy.minLength} />\n {passwordDescription ? (\n <p className=\"text-xs text-muted-foreground\">{passwordDescription}</p>\n ) : null}\n </div>\n <div className=\"grid gap-1\">\n <Label htmlFor=\"confirmPassword\">{t('auth.profile.form.confirmPassword', 'Confirm new password')}</Label>\n <Input\n id=\"confirmPassword\"\n name=\"confirmPassword\"\n type=\"password\"\n required\n minLength={passwordPolicy.minLength}\n />\n </div>\n <Button type=\"submit\" className=\"mt-2 w-full\" disabled={submitting}>\n {submitting ? t('auth.reset.form.loading', '...') : t('auth.reset.form.submit', 'Update password')}\n </Button>\n </form>\n </CardContent>\n </Card>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA8DQ,SACE,KADF;AA7DR,SAAS,MAAM,aAAa,YAAY,WAAW,uBAAuB;AAC1E,SAAS,cAAc;AACvB,SAAS,aAAa;AACt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-develop.2856.35de414092",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -237,10 +237,10 @@
|
|
|
237
237
|
"ts-pattern": "^5.0.0"
|
|
238
238
|
},
|
|
239
239
|
"peerDependencies": {
|
|
240
|
-
"@open-mercato/shared": "0.5.1-develop.
|
|
240
|
+
"@open-mercato/shared": "0.5.1-develop.2856.35de414092"
|
|
241
241
|
},
|
|
242
242
|
"devDependencies": {
|
|
243
|
-
"@open-mercato/shared": "0.5.1-develop.
|
|
243
|
+
"@open-mercato/shared": "0.5.1-develop.2856.35de414092",
|
|
244
244
|
"@testing-library/dom": "^10.4.1",
|
|
245
245
|
"@testing-library/jest-dom": "^6.9.1",
|
|
246
246
|
"@testing-library/react": "^16.3.1",
|
|
@@ -23,9 +23,25 @@ export default function ResetWithTokenPage({ params }: { params: { token: string
|
|
|
23
23
|
async function onSubmit(e: React.FormEvent<HTMLFormElement>) {
|
|
24
24
|
e.preventDefault()
|
|
25
25
|
setError(null)
|
|
26
|
+
const form = new FormData(e.currentTarget)
|
|
27
|
+
const password = String(form.get('password') ?? '')
|
|
28
|
+
const confirmPassword = String(form.get('confirmPassword') ?? '')
|
|
29
|
+
|
|
30
|
+
if (!password) {
|
|
31
|
+
setError(t('auth.profile.form.errors.newPasswordRequired', 'New password is required.'))
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
if (!confirmPassword) {
|
|
35
|
+
setError(t('auth.profile.form.errors.confirmPasswordRequired', 'Please confirm the new password.'))
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
if (password !== confirmPassword) {
|
|
39
|
+
setError(t('auth.profile.form.errors.passwordMismatch', 'Passwords do not match.'))
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
|
|
26
43
|
setSubmitting(true)
|
|
27
44
|
try {
|
|
28
|
-
const form = new FormData(e.currentTarget)
|
|
29
45
|
form.set('token', params.token)
|
|
30
46
|
const { ok, result } = await apiCall<{ ok?: boolean; error?: string; redirect?: string }>(
|
|
31
47
|
'/api/auth/reset/confirm',
|
|
@@ -50,7 +66,7 @@ export default function ResetWithTokenPage({ params }: { params: { token: string
|
|
|
50
66
|
</CardHeader>
|
|
51
67
|
<CardContent>
|
|
52
68
|
<form className="grid gap-3" onSubmit={onSubmit}>
|
|
53
|
-
{error && <div className="text-sm text-
|
|
69
|
+
{error && <div className="text-sm text-status-error-text">{error}</div>}
|
|
54
70
|
<div className="grid gap-1">
|
|
55
71
|
<Label htmlFor="password">{t('auth.reset.form.password', 'New password')}</Label>
|
|
56
72
|
<Input id="password" name="password" type="password" required minLength={passwordPolicy.minLength} />
|
|
@@ -58,6 +74,16 @@ export default function ResetWithTokenPage({ params }: { params: { token: string
|
|
|
58
74
|
<p className="text-xs text-muted-foreground">{passwordDescription}</p>
|
|
59
75
|
) : null}
|
|
60
76
|
</div>
|
|
77
|
+
<div className="grid gap-1">
|
|
78
|
+
<Label htmlFor="confirmPassword">{t('auth.profile.form.confirmPassword', 'Confirm new password')}</Label>
|
|
79
|
+
<Input
|
|
80
|
+
id="confirmPassword"
|
|
81
|
+
name="confirmPassword"
|
|
82
|
+
type="password"
|
|
83
|
+
required
|
|
84
|
+
minLength={passwordPolicy.minLength}
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
61
87
|
<Button type="submit" className="mt-2 w-full" disabled={submitting}>
|
|
62
88
|
{submitting ? t('auth.reset.form.loading', '...') : t('auth.reset.form.submit', 'Update password')}
|
|
63
89
|
</Button>
|