From c208002788791d31fa88a8dd852bbe25dab94c08 Mon Sep 17 00:00:00 2001 From: "Akshay\" (aider)" Date: Fri, 8 Nov 2024 22:35:14 +0000 Subject: feat: Add registration page with password confirmation validation --- src/routes/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/routes/index.js b/src/routes/index.js index 533dabf..01101f5 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -71,9 +71,15 @@ router.get("/media/*", async (req, res) => { res.render("media", { kind, url }); }); -// POST /register +router.get("/register", async (req, res) => { + res.render("register"); +}); + router.post("/register", async (req, res) => { - const { username, password } = req.body; + const { username, password, confirm_password } = req.body; + if (password !== confirm_password) { + return res.status(400).send("Passwords do not match"); + } try { db.run("INSERT INTO users (username, password) VALUES (?, ?)", [ username, -- cgit v1.2.3