adds password max chars hint

This commit is contained in:
Christian Beutel
2025-02-16 20:46:31 +01:00
parent 95f78cb89a
commit 307736dfc2
17 changed files with 120 additions and 54 deletions

View File

@@ -8,8 +8,8 @@ export async function POST(event: RequestEvent) {
const data = await event.request.json()
const safeData = z.object({
token: z.string(),
password: z.string(),
passwordConfirm: z.string()
password: z.string().min(8).max(72),
passwordConfirm: z.string().min(8).max(72)
}).refine(d => d.password === d.passwordConfirm).parse(data)
const r = await pb.collection('users').confirmPasswordReset(safeData.token, safeData.password, safeData.passwordConfirm);
return json(r);

View File

@@ -9,7 +9,7 @@ export async function POST(event: RequestEvent) {
const safeData = z.object({
email: z.string().email().optional(),
username: z.string().optional(),
password: z.string()
password: z.string().min(8).max(72)
}).refine(d => d.email !== undefined || d.username !== undefined).parse(data);

View File

@@ -23,18 +23,34 @@
extend: validator({
schema: z
.object({
password: z.string().min(
8,
$_("must-be-at-least-n-characters-long", {
values: { n: 8 },
}),
),
passwordConfirm: z.string().min(
8,
$_("must-be-at-least-n-characters-long", {
values: { n: 8 },
}),
),
password: z
.string()
.min(
8,
$_("must-be-at-least-n-characters-long", {
values: { n: 8 },
}),
)
.max(
72,
$_("must-be-at-most-n-characters-long", {
values: { n: 72 },
}),
),
passwordConfirm: z
.string()
.min(
8,
$_("must-be-at-least-n-characters-long", {
values: { n: 8 },
}),
)
.max(
72,
$_("must-be-at-most-n-characters-long", {
values: { n: 72 },
}),
),
})
.refine((d) => d.password === d.passwordConfirm, {
message: "passwords-must-match",

View File

@@ -41,7 +41,15 @@
extend: validator({
schema: z.object({
username: z.string().min(1, "required"),
password: z.string().min(1, "required"),
password: z
.string()
.min(1, "required")
.max(
72,
$_("must-be-at-most-n-characters-long", {
values: { n: 72 },
}),
),
}),
}),
onSubmit: async (newUser) => {

View File

@@ -39,12 +39,20 @@
.string()
.min(1, "required")
.email("not-a-valid-email-address"),
password: z.string().min(
8,
$_("must-be-at-least-n-characters-long", {
values: { n: 8 },
}),
),
password: z
.string()
.min(
8,
$_("must-be-at-least-n-characters-long", {
values: { n: 8 },
}),
)
.max(
72,
$_("must-be-at-most-n-characters-long", {
values: { n: 72 },
}),
),
}),
}),
onSubmit: async (newUser) => {