From 61363cc400b28ceb1881367c259da5623836ac12 Mon Sep 17 00:00:00 2001 From: Chi Cong Tran Date: Thu, 7 Aug 2025 08:00:30 +0200 Subject: [PATCH] check if new account data is non-empty --- src/routes/api/users/+server.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/routes/api/users/+server.ts b/src/routes/api/users/+server.ts index ff164e3..b825346 100644 --- a/src/routes/api/users/+server.ts +++ b/src/routes/api/users/+server.ts @@ -19,6 +19,11 @@ export async function POST({ request, locals }) { const data = await request.json(); const userName = data.userName; const userPassword = data.userPassword; + + if (!userName || !userPassword) { + return json({ error: 'Missing input' }, { status: 400 }); + } + const rowCount = addUser(userName, userPassword); return new Response(null, { status: rowCount == 1 ? 200 : 400 });