diff options
author | Akshay" (aider) <[email protected]> | 2024-11-09 09:50:13 +0000 |
---|---|---|
committer | Akshay" (aider) <[email protected]> | 2024-11-09 09:50:13 +0000 |
commit | 02dcf1c1ab34c803eb8f3c66048fcd1d101774ae (patch) | |
tree | 604e9976991132b9695c19ad8ea4aefbb4244312 /src | |
parent | 7a727510109c1062ac9009df88db992791ee1ce8 (diff) |
fix: Add URL-encoded middleware and request body logging for /register endpoint
Diffstat (limited to 'src')
-rw-r--r-- | src/index.js | 1 | ||||
-rw-r--r-- | src/routes/index.js | 4 |
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")); | |||
10 | app.set("view engine", "pug"); | 10 | app.set("view engine", "pug"); |
11 | 11 | ||
12 | app.use(express.json()); | 12 | app.use(express.json()); |
13 | app.use(express.urlencoded({ extended: true })); | ||
13 | app.use(express.static(path.join(__dirname, "public"))); | 14 | app.use(express.static(path.join(__dirname, "public"))); |
14 | app.use("/", routes); | 15 | app.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 | ||
79 | router.post("/register", async (req, res) => { | 79 | router.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 | } |