aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkshay" (aider) <[email protected]>2024-11-09 09:50:13 +0000
committerAkshay" (aider) <[email protected]>2024-11-09 09:50:13 +0000
commit02dcf1c1ab34c803eb8f3c66048fcd1d101774ae (patch)
tree604e9976991132b9695c19ad8ea4aefbb4244312 /src
parent7a727510109c1062ac9009df88db992791ee1ce8 (diff)
fix: Add URL-encoded middleware and request body logging for /register endpoint
Diffstat (limited to 'src')
-rw-r--r--src/index.js1
-rw-r--r--src/routes/index.js4
2 files changed, 5 insertions, 0 deletions
diff --git a/src/index.js b/src/index.js
index cc7e2e6..4535edb 100644
--- a/src/index.js
+++ b/src/index.js
@@ -10,6 +10,7 @@ app.set("views", path.join(__dirname, "views"));
10app.set("view engine", "pug"); 10app.set("view engine", "pug");
11 11
12app.use(express.json()); 12app.use(express.json());
13app.use(express.urlencoded({ extended: true }));
13app.use(express.static(path.join(__dirname, "public"))); 14app.use(express.static(path.join(__dirname, "public")));
14app.use("/", routes); 15app.use("/", routes);
15 16
diff --git a/src/routes/index.js b/src/routes/index.js
index 6153692..2ee97e3 100644
--- a/src/routes/index.js
+++ b/src/routes/index.js
@@ -78,6 +78,10 @@ router.get("/register", async (req, res) => {
78 78
79router.post("/register", async (req, res) => { 79router.post("/register", async (req, res) => {
80 const { username, password, confirm_password } = req.body; 80 const { username, password, confirm_password } = req.body;
81 console.log("Request body:", req.body);
82 if (!username || !password || !confirm_password) {
83 return res.status(400).send("All fields are required");
84 }
81 if (password !== confirm_password) { 85 if (password !== confirm_password) {
82 return res.status(400).send("Passwords do not match"); 86 return res.status(400).send("Passwords do not match");
83 } 87 }