improved password requirements

This commit is contained in:
Oliver Bryan
2026-01-09 04:34:24 +00:00
parent dc50df15cb
commit de196c2e87

View File

@@ -31,8 +31,16 @@ export default async function register(req: BunRequest) {
return new Response("username must be 1-32 characters", { status: 400 }); return new Response("username must be 1-32 characters", { status: 400 });
} }
if (password.length < 1) { if (password.length < 8) {
return new Response("password must be at least 1 character", { status: 400 }); return new Response("password must be at least 8 characters", { status: 400 });
}
const hasUpperCase = /[A-Z]/.test(password);
const hasLowerCase = /[a-z]/.test(password);
const hasNumber = /[0-9]/.test(password);
if (!hasUpperCase || !hasLowerCase || !hasNumber) {
return new Response("password must contain uppercase, lowercase, and numbers", { status: 400 });
} }
const existing = await getUserByUsername(username); const existing = await getUserByUsername(username);