From d7187abedce86043c5c29174bf52737e37b10171 Mon Sep 17 00:00:00 2001 From: mawkone Date: Mon, 8 Jun 2026 10:45:26 -0700 Subject: [PATCH] feat(auth): make Name field required on signup --- vibn-frontend/app/api/auth/register/route.ts | 25 ++++++++++++++++--- .../app/components/auth/AuthScreen.tsx | 19 ++++++-------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/vibn-frontend/app/api/auth/register/route.ts b/vibn-frontend/app/api/auth/register/route.ts index 2a4bb19e..999257ef 100644 --- a/vibn-frontend/app/api/auth/register/route.ts +++ b/vibn-frontend/app/api/auth/register/route.ts @@ -19,13 +19,24 @@ export async function POST(request: Request) { try { body = await request.json(); } catch { - return NextResponse.json({ error: "Invalid request body." }, { status: 400 }); + return NextResponse.json( + { error: "Invalid request body." }, + { status: 400 }, + ); } - const email = String(body.email ?? "").trim().toLowerCase(); + const email = String(body.email ?? "") + .trim() + .toLowerCase(); const password = String(body.password ?? ""); - const name = body.name ? String(body.name).trim() : null; + const name = body.name ? String(body.name).trim() : ""; + if (!name) { + return NextResponse.json( + { error: "Enter your name to set up your workspace." }, + { status: 400 }, + ); + } if (!/^\S+@\S+\.\S+$/.test(email)) { return NextResponse.json( { error: "Enter a valid email address." }, @@ -64,7 +75,13 @@ export async function POST(request: Request) { const workspace = email.split("@")[0].replace(/[^a-z0-9]+/g, "-") + "-account"; const passwordHash = await hashPassword(password); - const data = JSON.stringify({ email, name, image: null, workspace, passwordHash }); + const data = JSON.stringify({ + email, + name, + image: null, + workspace, + passwordHash, + }); const fsRows = await query<{ id: string }>( `INSERT INTO fs_users (id, user_id, data) VALUES (gen_random_uuid()::text, $1, $2::jsonb) diff --git a/vibn-frontend/app/components/auth/AuthScreen.tsx b/vibn-frontend/app/components/auth/AuthScreen.tsx index 7f6e6d0b..5594b95e 100644 --- a/vibn-frontend/app/components/auth/AuthScreen.tsx +++ b/vibn-frontend/app/components/auth/AuthScreen.tsx @@ -27,7 +27,12 @@ export default function AuthScreen({ const [error, setError] = useState(null); const emailValid = /\S+@\S+\.\S+/.test(email); - const canSubmit = emailValid && password.length >= 8 && !submitting; + const canSubmit = isSignup + ? emailValid && + password.length >= 8 && + name.trim().length > 0 && + !submitting + : emailValid && password.length >= 8 && !submitting; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -148,21 +153,13 @@ export default function AuthScreen({ {isSignup && (