From 9eefb5ee38545d88ac14c69138710c3bcbbbd676 Mon Sep 17 00:00:00 2001 From: IM23a-spirgif Date: Tue, 29 Apr 2025 16:20:31 +0200 Subject: [PATCH] Fixed a bug with login --- gambling.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gambling.js b/gambling.js index 7ad33f6..08a4ad6 100644 --- a/gambling.js +++ b/gambling.js @@ -93,6 +93,7 @@ app.get("/login", (request, response) => { app.post("/login", (request, response) => { let {username, password} = request.body; username = username.toLowerCase(); + if (!username || !password) return response.status(400).json({error: "Username and password are required"}); @@ -101,7 +102,7 @@ app.post("/login", (request, response) => { if (!user) return response.status(401).json({error: "Invalid credentials"}); if (user.password !== password) { - response.status(401).json({error: "Invalid password"}); + return response.status(401).json({error: "Invalid password"}); } const token = generateAccessToken({username});